创建归一化直方图并在 Matlab 上使用伽玛分布对其进行拟合
我知道我可以通过这种方式拟合具有伽玛分布的直方图:
histfit(data,bins-number,'gamma');figure(gcf);
我也知道我可以标准化带有 histnorm 的直方图。但是如何用直方图创建归一化伽玛分布呢?
有什么想法或建议吗?感谢您的帮助!
I know that I can fit a histogram with a gamma distribution in this way:
histfit(data,bins-number,'gamma');figure(gcf);
And I know too that I can normalize a histogram with histnorm. But how can I create a normalized gamma distribution with its histogram?
Any idea or suggestion? Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
为了回应 BruceWarrior 下面的评论,
histfit
将为您标准化数据......只需将x
替换为您的数据即可。如果您想知道如何自己标准化直方图,使其成为概率密度,查看我对这个问题的回答。请注意,接受的答案不会为您提供概率密度(即曲线下面积不会为 1)。您可以使用
gamrnd
函数来为给定的形状参数a
和尺度参数b
生成具有伽玛分布的随机变量。然后,您可以对此调用histfit
将 Gamma 分布拟合到归一化直方图的数据。下面是一个示例:a=1,b=2
a=2, b=2
EDIT:
In response to BruceWarrior's comment below,
histfit
will normalize the data for you... just replacex
with your data. If you want to know how to normalize a histogram yourself such that it is a probability density, see my answer to that very question. Note that the accepted answer will not give you a probability density (i.e., the area under the curve will not be 1).You can use the
gamrnd
function to generate random variables with a Gamma distribution for a given shape parametera
and scale parameterb
. You can then callhistfit
on this data to fit the Gamma distribution to the normalized histogram. Here's an example:a=1,b=2
a=2, b=2