【发布时间】:2017-07-03 02:08:40
【问题描述】:
我有四组数据,我想在 MATLAB 中用一张图表示它们的分布。当前代码是:
[n1,x1]=hist([dataset1{:}]);
[n2,x2]=hist([dataset2{:}]);
[n3,x3]=hist([dataset3{:}]);
[n4,x4]=hist([dataset4{:}]);
bar(x1,n1,'hist');
hold on; h1=bar(x1,n1,'hist'); set(h1,'facecolor','g')
hold on; h2=bar(x2,n2,'hist'); set(h2,'facecolor','g')
hold on; h3=bar(x3,n3,'hist'); set(h3,'facecolor','g')
hold on; h4=bar(x4,n4,'hist'); set(h4,'facecolor','g')
hold off
我的问题是我对每个组有不同的采样大小,dataset1 的 n 为 69,dataset2 的 n 为 23,dataset3 和 dataset4 的 n 为 10。那么在表示这三个组时如何对分布进行归一化一起?
有什么方法可以...例如..将每个 bin 中的实例除以该组的采样吗?
【问题讨论】:
-
为什么不改用
n1/sum(n1)呢?否则,也许histogram(x,'Normalization','probability')会是一个替代方案。 -
n1/sum(n1) 效果很好,有没有办法用 histfit 做到这一点?或者一些更好/更简单的方法来添加拟合线?
标签: matlab histogram distribution normalize bins