interstellar
interstellar

Reputation: 399

Fit poisson distribution to data

I have plotted a histogram and would like to fit a poisson distribution to the histogram. To do this, I have passed the x and y histogram coordinate vector to the poissfit() function to estimate lambda.

For example, here is what I've done:

expecteddata = cat(2,x,y)
[l,lci] = poissfit(expecteddata)

My output looks like so:

l =

   44.3766    0.0130


lci =

   42.8887    0.0003
   45.8645    0.0724

I'm assuming the the lambda I'm interested in for plotting would be 0.013 (I think my lambda is so small because my histogram is a frequency histogram). I plot the poisson pdf using:

x = 0:50
y = poisspdf(x,0.013);
plot(x,y,'r')

And I get the resulting overlayed plot:

enter image description here

However, I think this fitted distribution looks a little odd. It doesn't appear to be very "poisson" like. Does anyone know if I'm doing anything incorrectly?

Upvotes: 1

Views: 3975

Answers (1)

Boss_Bandor
Boss_Bandor

Reputation: 52

"I have plotted a histogram and would like to fit a poisson distribution to the histogram."

What I understand is you need to fit poisson distribution to a existing histogram of measured data. I believe you can use the fitdist() function.

For example, if your data is x.

[n,bin]=hist(x,100);
m=n/trapz(bin,n);
bar(bin,m,'w');
hold on
pd=fitdist(x,'poisson');
y=pdf(pd,bin);
plot(bin,y,'k');
hold off;

will give you a histogram with a poisson distributed curve fitted to it.

Upvotes: 2

Related Questions