For arbitrary lambda_i it can take years until the sum of 50 such random variables is 100! But if one makes lambda_i = 2, then the probability that the sum of 50 of them equals 100 is about 1/sqrt(2*pi*100), so on average that sequence of 50 numbers must be generated about sqrt(2*pi*100)) ~ 25 times, which is very reasonable.
--- On Tue, 8/7/08, Peng Jiang <[EMAIL PROTECTED]> wrote: > From: Peng Jiang <[EMAIL PROTECTED]> > Subject: Re: [R] Sum(Random Numbers)=100 > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED], "Shubha Vishwanath Karanth" <[EMAIL PROTECTED]> > Received: Tuesday, 8 July, 2008, 4:56 PM > Hi, > I am afraid there is no other way except using brute > force, that > is , loop until their sum reaches your expectation. > it is easy to figure out this probability by letting > their sum to be > a new random variable Z and Z = X_1 + \ldots + X_n > where X_i ~ Poisson({\lambda}_i) . By calculating > their moment > generate function we can find the pmf of Z which is > a new Poisson random variable with the parameter > \sum_{i}{{\lambda}_i}. > > and Moshe Olshansky's method is also correct except > it is based on > the conditioning. > On 2008-7-8, at 下午1:58, Shubha Vishwanath Karanth > wrote: > On 2008-7-8, at 下午2:39, Moshe Olshansky wrote: > > > If they are really random you can not expect their sum > to be 100. > > However, it is not difficult to get that given that > the sum of n > > independent Poisson random variables equals N, any > individual one > > has the conditional binomial distribution with size = > N and p = 1/n, > > i.e. > > P(Xi=k/Sn=N) = (N over k)*(1/n)^k*((n-1)/n)^(N-k). > > So you can generate X1 binomial with size = 100 and p > = 1/50; if X1 > > = k1 then the sum of the rest 49 must equal 100 - k1, > so now you > > generate X2 binomial with size = 100-k1 and p = 1/49; > if X2 = k2 > > then generate X3 binomial with size = 100 -(k1+k2) and > p = 1/48, etc. > > > > Why do you need this? > > > > > > --- On Tue, 8/7/08, Shubha Vishwanath Karanth > <[EMAIL PROTECTED] > > > wrote: > > > >> From: Shubha Vishwanath Karanth > <[EMAIL PROTECTED]> > >> Subject: [R] Sum(Random Numbers)=100 > >> To: [EMAIL PROTECTED] > >> Received: Tuesday, 8 July, 2008, 3:58 PM > >> Hi R, > >> > >> > >> > >> I need to generate 50 random numbers (preferably > poisson), > >> such that > >> their sum is equal to 100. How do I do this? > >> > >> > >> > >> > >> > >> Thank you, > >> > >> Shubha > >> > >> > >> > >> This e-mail may contain confidential and/or > privileged > >> i...{{dropped:13}} > >> > >> ______________________________________________ > >> R-help@r-project.org 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. > > > > ______________________________________________ > > R-help@r-project.org 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. > > ----------------------------------------------- > Peng Jiang 江鹏 ,Ph.D. Candidate > Antai College of Economics & Management > 安泰经济管理学院 > Department of Mathematics > 数学系 > Shanghai Jiaotong University (Minhang Campus) > 800 Dongchuan Road > 200240 Shanghai > P. R. China ______________________________________________ R-help@r-project.org 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.