[R] generate random numbers that sum up to 1

Alberto Monteiro albmont at centroin.com.br
Mon Oct 16 17:22:04 CEST 2006


Grant Izmirlian wrote:
>
> So,  Alberto, you didn't see my post?
>
I think I didn't - but you are demanding too much from my memory;
I can hardly remember what I saw yesterday!

> If Y has d independent 
> components that are gamma distributed with common rate and shapes 
> A_1, A_2, ..., A_d, then X, given by the components of Y divided by 
> their sum has distribution Dirichlet(A_1, A_2, ..., A_d).  If you 
> want Uniform on the d-simplex, then use A_1 = A_2 = ... = A_d = 1 
> (just as Duncan said)
> 
The problem is that I wasn't aware that this was the Dirichlet
distribution [R does not have this distribution, AFAIK, but I
should have consulted the Borg of All Wisdom, the Wikipedia].

Alberto Monteiro



More information about the R-help mailing list