0

我想使用 histfit 从绘图中获取密度曲线方程。

我看到使用 ksdensity 函数可以获得点向量。这是最好的方法吗?

4

1 回答 1

8
histfit(data);

将数据绘制为直方图,并显示最佳拟合高斯的平滑曲线。

[mu, sigma] = normfit(data);
pd = fitdist(data,'normal');

将给出同一组数据的平均值 (mu) 和标准差 (sigma),由 histfit 用于生成拟合曲线。

如果你这样做edit histfit,你可以查看它,通过将正态曲线下的面积和直方图中的面积相等来找到正态曲线的高度,查找周围的代码

% Normalize the density to match the total area of the histogram
xd = get(hh,'Xdata');             % Gets the x-data of the bins.
rangex = max(xd(:)) - min(xd(:)); % Finds the range of this data.
binwidth = rangex/nbins;          % Finds the width of each bin.
area = n * binwidth;
y = area * pdf(pd,x);

有关进行缩放的那部分的更多提示。

于 2012-05-31T06:18:52.947 回答