Fit poisson distribution to data

旧巷老猫 提交于 2019-12-08 07:42:34

问题


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:

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?


回答1:


"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.



来源:https://stackoverflow.com/questions/38249508/fit-poisson-distribution-to-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!