如何将双模态分布拟合到函数matlab中

时间:2016-05-20 14:54:00

标签: matlab distribution function-fitting

我有一个名为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. 的参数
  4. 评估它是否合适(即分布是双模态的)。
  5. 你能帮我吗?

1 个答案:

答案 0 :(得分:0)

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

pd = fitdist(y,'Normal')