lemniscates: Sample (with noise) from lemniscates (figure eights)

lemniscatesR Documentation

Sample (with noise) from lemniscates (figure eights)

Description

These functions generate uniform samples from lemniscates (figure eights) in 2-dimensional space, optionally with noise.

Usage

sample_lemniscate_gerono(n, sd = 0)

Arguments

n

Number of observations.

sd

Standard deviation of (independent multivariate) Gaussian noise.

Details

These functions use a simple parameterization from the unit circle to the lemniscate of Gerono, as presented on Wikipedia. The uniform sample is generated through a rejection sampling process as described by Diaconis, Holmes, and Shahshahani (2013).

References

P Diaconis, S Holmes, and M Shahshahani (2013) Sampling from a Manifold. Advances in Modern Statistical Theory and Applications: A Festschrift in honor of Morris L. Eaton, 102–125. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/12-IMSCOLL1006")}

Examples

set.seed(12051L)

# Uniformly sampled figure eight in 2-space
x <- sample_lemniscate_gerono(720)
plot(x, asp = 1, pch = 19, cex = .5)

# Naively sampled figure eight, for comparison
theta <- runif(n = 720, min = 0, max = 2*pi)
x_naive <- cbind(x = cos(theta), y <- cos(theta) * sin(theta))
plot(x_naive, asp = 1, pch = 19, cex = .5)

# Uniformly sampled figure eight in 2-space with Gaussian noise
x <- sample_lemniscate_gerono(720, 0.1)
plot(x, asp = 1, pch = 19, cex = .5)

corybrunson/tdaunif documentation built on Feb. 2, 2024, 8:22 p.m.