【问题标题】:MATLAB histfit - get PDF from data, ksdensity?MATLAB histfit - 从数据中获取 PDF,ksdensity?
【发布时间】:2012-05-31 02:57:21
【问题描述】:

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

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

【问题讨论】:

    标签: matlab plot probability histogram


    【解决方案1】:
    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);
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-22
      • 2012-05-10
      • 2015-04-18
      • 1970-01-01
      • 2021-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多