random_init_simplex: Generates a random point in the (p-1)-simplex.
Description
Generates a random point in the (p-1)-simplex.
Usage
random_init_simplex(p, rdist = stats::rnorm, tol = 1e-10, maxtimes = 100)
Value
A random point (p-vector) in the (p-1)-simplex, i.e. sum(x) == 1 && x > 0.
Arguments
p
An integer, the dimension.
rdist
A function that generates a random number when called using rdist(1). Must return a non-zero number with a large enough probability.
tol
A small positive number. Samples are regenerated until each of the p components are at least of size tol.
maxtimes
An integer, maximum number of attempts.
Details
p numbers are generated from rdist and their absolute values are normalized to sum to 1. This will be repeated up to maxtimes times until all p components are larger than or equal to tol.