如何通过标量乘以直方图中的频率

时间:2017-10-17 11:37:39

标签: matlab histogram

我正在使用Matlab(更好的主意)。

我需要将直方图的频率乘以标量值(对于每个bin)。 我在similar question中尝试了这种方法,但它是为hist而不是直方图函数定义的。 这是我原来需要增加的分布: orinial

这是我使用类似问题中给出的方法得到的: applied

此外,当我完成这部分时,我将有更多的直方图,我需要总结成一个直方图。那我该怎么做?他们可能有不同的范围。

2 个答案:

答案 0 :(得分:2)

文档clearly explains如何使用hist复制histogram的行为。

例如:

A = rand(100, 1);
h = histogram(A);

figure
h_new = histogram('BinCounts', h.Values*2, 'BinEdges', h.BinEdges);

生成以下直方图:

yay yay2

答案 1 :(得分:2)

您可以像这样修改Bincounts:

X = normrnd(0,1,1000,1); % some data
h = histogram(X,3); % histogram with 3 bins
h.BinCounts = h.Values.*[3 5 1]; % scale each bin by factor 3, 5 and 1 respectively