[R] Generate random numbers up to one

2007-03-06 Thread Núria Martínez
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 _ Acepta el reto MSN Premium: Correos más divertidos con

Re: [R] Generate random numbers up to one

2007-03-06 Thread Petr Klasterecky
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

Re: [R] Generate random numbers up to one

2007-03-06 Thread Barry Rowlingson
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

Re: [R] Generate random numbers up to one

2007-03-06 Thread Peter Dalgaard
Núria Martínez wrote: 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... The easiest way is to generate them by whatever method and divide by their sum. e.g. as (s-rexp(100))/sum(s) Are

Re: [R] Generate random numbers up to one

2007-03-06 Thread Petr Klasterecky
Barry Rowlingson napsal(a): 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)

Re: [R] Generate random numbers up to one

2007-03-06 Thread Ted Harding
On 06-Mar-07 Petr Klasterecky wrote: Barry Rowlingson napsal(a): 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

Re: [R] Generate random numbers up to one

2007-03-06 Thread Alberto Monteiro
Ted Harding wrote: And, specifically (to take just 2 RVs X and Y), while U = X/(X+Y) and V = Y/(A+Y) are two RVs which summ to 1, the distribution of U is not the same as the distribution of X conditional on (X+Y = 1). This question appeared in October 2006, and the answer was the Dirichlet

Re: [R] Generate random numbers up to one

2007-03-06 Thread Ted Harding
On 06-Mar-07 Alberto Monteiro wrote: Ted Harding wrote: And, specifically (to take just 2 RVs X and Y), while U = X/(X+Y) and V = Y/(A+Y) are two RVs which summ to 1, the distribution of U is not the same as the distribution of X conditional on (X+Y = 1). This question Which question?