[R] generate random numbers that sum up to 1
Ben Fairbank
BEN at SSANET.COM
Tue Oct 10 16:10:37 CEST 2006
The trick is in defining "random" in the face of the three apparently
incompatible constraints that the numbers be random, that they sum to 1,
and that they be uniformly distributed. Tell us more. Perhaps extend
Peter D's solution by first deciding (at random) how many components
each solution will have.
Ben Fairbank
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of sun
Sent: Tuesday, October 10, 2006 8:28 AM
To: r-help at stat.math.ethz.ch
Subject: [R] generate random numbers that sum up to 1
I am trying to generate a vector of random numbers with the constraint
that they have to sum up to one with uniform distribution.
eg. {0.1,0.7,0.2 }
any function to do this? Thanks.
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list