【问题标题】:how to fit a bi-modal distribution to a function matlab如何将双峰分布拟合到函数 matlab
【发布时间】:2016-05-20 14:53:59
【问题描述】:

我有一个名为 speed 的向量,其中包含 200 次步行的速度

speed = [normrnd(80,2,100,1); normrnd(120,10,100,1)];

这个向量服从双峰分布。

steps 是另一个包含每次行走步数的向量:

a = 8;
b = 100;
steps = (b-a).*rand(200,1) + a;

我创建了根据速度执行的步骤的直方图:

binstep = 1.5;
binranges = (min(speed):binstep:max(speed)+binstep)';
[~, ind] = histc(speed, binranges);
bincounts = accumarray(ind, steps, size(binranges));
hFig = figure(); axh = axes('Parent', hFig); hold(axh, 'all'); grid(axh, 'on');
bar(axh, binranges, bincounts); axis(axh, 'tight');

现在我想

  1. 将双峰分布拟合到条形图,
  2. 估计双峰分布的参数 u1,u2,sigma1,sigma2,
  3. 评估它是否合适(即分布是双模态的)。

你能帮帮我吗?

【问题讨论】:

  • 我认为mathworks documentation 看起来像你想要的
  • 谢谢!但是为什么他们在绘制 h = bar(bins,histc(x,bins)/(length(x)*.5),'histc') 时划分为 (length(x)*.5);

标签: matlab distribution function-fitting


【解决方案1】:

要将数据拟合到分布,只需使用 fitdist 函数。 在您的情况下,使用 Normal 将是:

pd = fitdist(y,'Normal')

【讨论】:

    猜你喜欢
    • 2021-10-15
    • 2012-07-16
    • 1970-01-01
    • 2014-01-15
    • 2012-05-17
    • 2017-04-11
    • 2012-08-06
    • 1970-01-01
    • 2016-01-14
    相关资源
    最近更新 更多