Generate 3 random number that sum to 1 in R

Posted by user1034797 on Stack Overflow See other posts from Stack Overflow or by user1034797
Published on 2012-06-12T20:02:45Z Indexed on 2012/06/12 22:40 UTC
Read the original article Hit count: 132

Filed under:
|

I am hoping to create 3 (non-negative) quasi-random numbers that sum to one, and repeat over and over.

Basically I am trying to partition something into three random parts over many trials.

While I am aware of

a= runif(3,0,1)

I was thinking that I could use 1-a as the max in the next run if, but it seems messy.

But these of course don't sum to one. Any thoughts, oh wise stackoverflow-ers?

© Stack Overflow or respective owner

Related posts about r

    Related posts about random