[R] Generate random numbers up to one

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Mar 6 15:36:55 CET 2007


Petr Klasterecky wrote:

> 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)

  I see a slight problem that may occur with dividing by sum(x) in 
certain cases....

Barry



More information about the R-help mailing list