【发布时间】:2012-05-31 02:57:21
【问题描述】:
我想使用 histfit 从绘图中得到密度曲线方程。
我看到使用 ksdensity 函数可以获得点向量。这是最好的方法吗?
【问题讨论】:
标签: matlab plot probability histogram
我想使用 histfit 从绘图中得到密度曲线方程。
我看到使用 ksdensity 函数可以获得点向量。这是最好的方法吗?
【问题讨论】:
标签: matlab plot probability histogram
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);
有关进行这部分缩放的更多提示。
【讨论】: