[R] Generate random numbers up to one
Petr Klasterecky
klaster at karlin.mff.cuni.cz
Tue Mar 6 15:25:17 CET 2007
Núria Martínez napsal(a):
> Dear all,
>
> I would like to know if there is a simple way to generate random numbers
> with the constrain that they sum up to one. I am new using R...
>
> Thanks in advance,
>
> Núria
You need to specify what 'random' means. If you have any numbers, you
can always make them add-up to 1:
x <- rnorm(100) #runif(100), rpois(100) etc.
x <- x/sum(x)
sum(x)
Petr
--
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic
More information about the R-help
mailing list