runif_in_simplex: Uniform sampling in a simplex

Description Usage Arguments Value Note Examples

View source: R/simplex.R

Description

Uniform sampling in a simplex (arbitrary dimension).

Usage

1
runif_in_simplex(n, simplex)

Arguments

n

number of simulations

simplex

a (d+1) times d matrix giving the vertices of the simplex (rows)

Value

The simulations in a n times d matrix.

Note

In dimension 3, you can use runif_in_tetrahedron instead.

Examples

1
2
3
4
simplex <- rbind(c(0,0,0), c(1,0,0), c(1,1,0), c(1,1,2))
sims <- runif_in_simplex(1000, simplex)
library(rgl)
points3d(sims)

stla/uniformly documentation built on Aug. 10, 2018, 7:03 a.m.