Uniform sampling in a tetrahedron (in dimension 3).
runif_in_tetrahedron(n, v1, v2, v3, v4)
number of simulations
vertices of the tetrahedron
The simulations in a
runif_in_simplex for sampling in a simplex in
library(rgl) tetrahedron <- tetrahedron3d() shade3d(tetrahedron, color = "red", alpha = 0.3) vs <- tetrahedron$vb[1L:3L, ] sims <- runif_in_tetrahedron(100, vs[, 1], vs[, 2], vs[, 3], vs[, 4]) points3d(sims)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.