Re: PoissonDistribution
- To: mathgroup at smc.vnet.net
- Subject: [mg16990] Re: [mg16949] PoissonDistribution
- From: BobHanlon at aol.com
- Date: Sat, 10 Apr 1999 02:13:30 -0400
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 4/8/99 1:57:53 PM, b.kaestner1 at physics.ox.ac.uk writes:
>I have a problem using the Statistics`DiscreteDistributions` package and
>was
>wondering if anybody sees the same strange effekt, or even better, has
>a
>solution to it.
>
>The following command should produce a list of 10000 poisson distributed
>numbers with mean <n>=100 :
>
><<Statistics`DiscreteDistributions`
>poissonList=RandomArray[PoissonDistribution[100],10000];
>
>For a poison distribution one should have <n>=<(n-<n>)^2> which also
>Mathematica knows:
>
>In[92]:=psList=PoissonDistribution[100]
>Out[92]=PoissonDistribution[100]
>
>In[93]:=Mean[psList]
>Out[93]=100
>
>In[94]:=Variance[psList]
>Out[94]=100
>
>However, when plotting the simulated values poissonList :
>
><<Statistics`DataManipulation`
>freq=Frequencies[poissonList]
>ListPlot[Table[{freq[[i,2]],freq[[i,1]]},{i,Length[freq]}],PlotRange->All]
>
>Mathematica cuts off the lower half of the distribution, and produces
>instead over 4000 (out of 10000) times the value 99.
>
>Just in case it makes a difference: I have an IBM ThinkPad 1400, intel
>pentium MMX 300MHz and tried it also on another pentium computer.
>
>I would be glad some of you could try this as well, or provide a solution
>for how to use this command.
>
Bernd,
Needs["Statistics`DiscreteDistributions`"]
Your name for your distribution is misleading. PoissonDistribution[mu]
is not a list, it is the definition of the distribution.
psDist = PoissonDistribution[mu];
{PDF[psDist, n], Mean[psDist], Variance[psDist]}
{(Exp[-mu]*mu^n)/n!, mu, mu}
poissonList=RandomArray[PoissonDistribution[100],500];
{Mean[poissonList], Variance[poissonList]}//N
{99.922,97.7995}
Needs["Statistics`DataManipulation`"]
Needs["Graphics`Graphics`"]
freq = Frequencies[poissonList];
I don't understand what you mean by "Mathematica cuts off the
lower half of the distribution". With a mean of 100 and a
standard deviation of 10, you would not expect to see values
below around three sigma (3*10=30) from the mean, i.e., below
70. I don't have a problem plotting using your function
(I only used 500 data values).
ListPlot[Table[{freq[[i,2]],freq[[i,1]]},{i,Length[freq]}],PlotRange->All];
However, I would recommend using a bar chart.
BarChart[freq,PlotLabel ->
"Poisson Distribution (mu = 100)"];
To make the x-axis legible
BarChart[freq,Ticks -> {Table[{k-Min[Transpose[freq][[2]]],k},
{k, 80, 120, 5}], Automatic},
PlotLabel -> "Poisson Distribution (mu = 100)"];
If you bin the data, it is easier to see
freq = BinCounts[poissonList, {72.5, 132.5, 5}];
midPoints = Table[k, {k,75, 130, 5}];
BarChart[Transpose[{freq, midPoints}], PlotLabel ->
"Poisson Distribution (mu = 100)"];
Bob Hanlon