## Area of S^{p - 1}
# Areas of S^0, S^1, and S^2
w_p(p = 1:3)
# Area as a function of p
p <- 1:20
plot(p, w_p(p = p), type = "o", pch = 16, xlab = "p", ylab = "Area",
main = expression("Surface area of " * S^{p - 1}), axes = FALSE)
box()
axis(1, at = p)
axis(2, at = seq(0, 34, by = 2))
## Simulation and density evaluation for p = 1, 2, 3
# p = 1
n <- 500
x <- r_unif_sphere(n = n, p = 1)
barplot(table(x) / n)
head(d_unif_sphere(x))
# p = 2
x <- r_unif_sphere(n = n, p = 3)
plot(x)
head(d_unif_sphere(x))
# p = 3
x <- r_unif_sphere(n = n, p = 3)
if (requireNamespace("rgl")) {
rgl::plot3d(x)
}
head(d_unif_sphere(x))
Run the code above in your browser using DataLab