runif_in_simplex: Uniform sampling in a simplex

View source: R/simplex.R

runif_in_simplexR Documentation

Uniform sampling in a simplex

Description

Uniform sampling in a simplex (arbitrary dimension).

Usage

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

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)

uniformly documentation built on July 26, 2023, 6:06 p.m.