使泊松分布适合数据 [英] Fit poisson distribution to data
问题描述
我已经绘制了直方图,并希望将泊松分布拟合到直方图.为此,我已将x和y直方图坐标向量传递给poissfit()
函数以估计lambda.
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.
例如,这是我所做的:
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
我假设对绘制感兴趣的lambda为0.013
(我认为我的lambda很小,因为我的直方图是频率直方图).我使用以下方法绘制了泊松pdf格式:
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?
推荐答案
我已经绘制了直方图,并希望将泊松分布拟合到直方图."
"I have plotted a histogram and would like to fit a poisson distribution to the histogram."
我了解的是,您需要将泊松分布与现有的测量数据直方图拟合.我相信您可以使用fitdist()
函数.
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.
例如,如果您的数据是x
.
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.
这篇关于使泊松分布适合数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!