【问题标题】:Histogram (hist) not starting (and ending) in zero直方图(hist)不以零开始(和结束)
【发布时间】:2014-06-03 20:31:21
【问题描述】:

我正在使用 Matlab 函数“hist”来估计我所拥有的随机过程实现的概率密度函数。

其实我是:

1) 取h0的直方图

2) 对其面积进行归一化以获得 1

3) 绘制归一化曲线。

问题是,无论我使用多少个 bin,直方图永远不会从 0 开始,也永远不会回到 0,而我真的很喜欢这种行为。

我使用的代码如下:

    Nbin = 36;
   [n,x0] = hist(h0,Nbin);
   edge = find(n~=0,1,'last');
   Step = x0(edge)/Nbin;
   Scale_factor = sum(Step*n);
   PDF_h0 = n/Scale_factor;

   hist(h0 ,Nbin)  %plot the histogram
   figure;
   plot(a1,p_rice); %plot the theoretical curve in blue 
   hold on;
   plot(x0, PDF_h0,'red'); %plot the normalized curve obtained from the histogram

我得到的情节是:

【问题讨论】:

  • 看看 histc (bar(histc(x,[h0:1/nbins:2])))

标签: matlab histogram probability probability-density


【解决方案1】:

如果您的问题是 绘制的红色曲线没有变为零:您可以解决添加 y 轴值 0 的初始点和最终点的问题。从您的代码看来,x 轴分离是Step,所以应该是:

plot([x0(1)-Step x0 x0(end)+Step], [0 PDF_h0 0], 'red')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-20
    • 2021-04-15
    • 1970-01-01
    • 2015-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多