| r_path_s1r | R Documentation |
Functions for sampling data on (\mathbb{S}^d)^r, for
d=1,2, using one-dimensional modes of variation.
r_path_s1r(
n,
r,
alpha = runif(r, -pi, pi),
k = sample(-2:2, size = r, replace = TRUE),
sigma = 0.25,
angles = FALSE
)
r_path_s2r(
n,
r,
t = 0,
c = 1,
Theta = t(rotasym::r_unif_sphere(n = r, p = 3)),
kappa = 0,
sigma = 0.25,
spiral = FALSE
)
n |
sample size. |
r |
number of spheres in the polysphere |
alpha |
a vector of size |
k |
a vector of size |
sigma |
standard deviation of the noise about the one-dimensional mode
of variation. Defaults to |
angles |
return angles in |
t |
latitude, with respect to |
c |
Clélie curve parameter,
changing the spiral wrappings. Defaults to |
Theta |
a matrix of size |
kappa |
concentration von Mises–Fisher parameter for longitudes in
small circles. Defaults to |
spiral |
consider a spiral (or, more precisely, a
Clélie curve) instead of a small
circle? Defaults to |
An array of size c(n, d, r) with samples on (\mathbb{S}^d)^r.
If angles = TRUE for r_path_s1r, then a matrix of size
c(n ,r) with angles is returned.
r_unif_polysph, r_vmf_polysph,
r_mvmf_polysph, r_kern_polysph,
r_kde_polysph.
if (requireNamespace("sdetorus", quietly = TRUE)) {
# Straight trends on (S^1)^2
n <- 100
samp_1 <- r_path_s1r(n = n, r = 2, k = c(1, 2), angles = TRUE)
plot(samp_1, xlim = c(-pi, pi), ylim = c(-pi, pi), col = rainbow(n),
axes = FALSE, xlab = "", ylab = "", pch = 16)
sdetorus::torusAxis()
}
if (requireNamespace("sdetorus", quietly = TRUE) &&
requireNamespace("scatterplot3d", quietly = TRUE)) {
# Straight trends on (S^1)^3
n <- 100
samp_2 <- r_path_s1r(n = n, r = 3, angles = TRUE)
pairs(samp_2, xlim = c(-pi, pi), ylim = c(-pi, pi), col = rainbow(n),
pch = 16)
sdetorus::torusAxis()
scatterplot3d::scatterplot3d(
samp_2, xlim = c(-pi, pi), ylim = c(-pi, pi), zlim = c(-pi, pi),
xlab = "", ylab = "", zlab = "", color = rainbow(n), pch = 16
)
# Small-circle trends on (S^2)^2
n <- 100
samp_3 <- r_path_s2r(n = n, r = 2, sigma = 0.1, kappa = 5)
old_par <- par(mfrow = c(1, 2))
scatterplot3d::scatterplot3d(
samp_3[, , 1], xlim = c(-1, 1), ylim = c(-1, 1), zlim = c(-1, 1),
xlab = "", ylab = "", zlab = "", color = rainbow(n), pch = 16
)
scatterplot3d::scatterplot3d(
samp_3[, , 2], xlim = c(-1, 1), ylim = c(-1, 1), zlim = c(-1, 1),
xlab = "", ylab = "", zlab = "", color = rainbow(n), pch = 16
)
par(old_par)
# Spiral trends on (S^2)^2
n <- 100
samp_4 <- r_path_s2r(n = n, r = 2, c = 3, spiral = TRUE, sigma = 0.01)
old_par <- par(mfrow = c(1, 2))
scatterplot3d::scatterplot3d(
samp_4[, , 1], xlim = c(-1, 1), ylim = c(-1, 1), zlim = c(-1, 1),
xlab = "", ylab = "", zlab = "", color = rainbow(n), pch = 16
)
scatterplot3d::scatterplot3d(
samp_4[, , 2], xlim = c(-1, 1), ylim = c(-1, 1), zlim = c(-1, 1),
xlab = "", ylab = "", zlab = "", color = rainbow(n), pch = 16
)
par(old_par)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.