均匀密度histfit

时间:2012-05-03 17:02:38

标签: matlab histogram

如何使用histfit()在直方图上绘制均匀密度?有一个命令要做正常分布和其他一些,所以我必须操纵其中一个来制服?

示例:

s4 = randn(50,1);
counts = [];
[counts(1,:) freq] = histc(s4, [-inf,-3]);
for n = 2:7
    [counts(n,:) freq] = histc(s4, [-5+n,-4+n]);
end
[counts(8,:) freq] = histc(s4, [3,inf]);
counts(1:8)
histfit(s4).

如何实现统一直方图的histfit?

s = rand(50,1);
[count freq]= hist(s,5);
histfit(s);
count

1 个答案:

答案 0 :(得分:1)

如果您想要的只是直方图顶部的水平线,看起来就像您给出的示例,请尝试:

s4 = randn(50,1);
[N,X] = hist(s4,sqrt(numel(s4)));
bar(X,N);
hold on
plot([min(s4) max(s4)],[mean(N),mean(N)],'r','LineWidth',2);

这给了我一个直方图,水平线表示bin值的平均值。

相关问题