Re: Poisson random numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg3232] Re: Poisson random numbers
- From: txp at pi.net (JanHolland)
- Date: Mon, 19 Feb 1996 03:00:13 -0500
- Organization: txp
- Sender: owner-wri-mathgroup at wolfram.com
onm010 at uni-essen.de (Dr. Stefan P. Mueller) wrote: >Does anybody have a Poisson random number generator or do I have to write >my own? I could not find anything on MathSource. >Stefan >-- >Dr. Stefan P. Mueller, Nuklearmedizin, Universitaetsklinikum, Essen, > e-mail: onm010 at uni-essen.de, phone: <49> 201/ 723-4179, FAX: -5964 May be this is what you mean: average=2; p=PoissonDistribution[average]; d=Table[Random[p],{100}]; Short[d] xmax=Max[d,2*average,2] q=NormalDistribution[average,average^.5] e=BinCounts[d,{0,xmax,1}] (* which results from Poisson with freq y *) f=Sum[e[[y]],{y,1,xmax}] (* totaal of the frequenties *) g=N[e/f,2] (* relatieve frequenties, 2 cijfers precision *) ymax=Max[g] gauss=Plot[Evaluate[PDF[q,x]],{x,0,xmax} ,PlotRange->{0,1.5 ymax}] (*,Axes-> Automatic]*) (* Plot of the Gauss-distr[av,root(av)] *) poiss=BarChart[g, PlotRange -> {0,1.5 ymax}] (* idem of the Poisson[av] *) Show[poiss,gauss ,PlotLabel->"Poisson[2],Gauss[2,Root[2]]" (* ,AxesLabel->"Klaswaarde,Klasfrequentie" *) ,Ticks->{{{1,"0"},{6,"5"},{11,"10"},{16,"15"},{21,"20"},{26,"25"},{30,"30"},{35,"35"}} ,Automatic} ] It is inspired by: "Applied Mathematica" by Shaw/Tigg, Addison Wesley page 361 --------------------------------------------------------------- Jan Holland txp at pi.net Individual/society/state/environment never existed separately. They needed each other to survive, so ... Mutual assistance helps to survive=adapt=develop. I send personal e-mail-copy for information, but prefer reaction in the group. ==== [MESSAGE SEPARATOR] ====