Re: Sample uniformly from a simplex
- To: mathgroup at smc.vnet.net
- Subject: [mg94446] Re: Sample uniformly from a simplex
- From: Andreas <aagas at ix.netcom.com>
- Date: Sun, 14 Dec 2008 07:33:41 -0500 (EST)
I've kept thinking about this and came up with the following.
sampleSimplex[sampleSize_, dimensions_] :=
Module[{sample, sampleOutput},
sample = RandomReal[1, {sampleSize, dimensions}];
sampleOutput =
Table[1 / Total[sample[[i, All]]] *sample[[i, All]], {i, 1,
sampleSize}];
sampleOutput
]
example:
sampleSimplex[4, 3]
{{0.163972, 0.445817, 0.390211}, {0.470828, 0.291766,
0.237406}, {0.56663, 0.3813, 0.0520696}, {0.182715, 0.600876, 0.216409}}
This doesn't draw from an exponential distribution, but would this work?
Also, if it does work can I do it a better (faster, more elegant) way?