Histogram of overlaid standard normal draws
2 次查看(过去 30 天)
显示 更早的评论
The code below overlays histograms of two sets of standard normal draws. I also attach the graph itself. These draws are based on two Halton sequences, but that is (probably) not relevant to my question. Both sets use the same number of draws (3573) from the Halton sequence. I am a bit puzzled with the overlaid histograms. It looks as if the frequency count of one set (dark blue) is almost everywhere larger than that for the other set (white). But this is impossible because both sets have the same number of draws. That is, I would either expect a very close overlay, or that if one set has more counts at some regions, the other should have more at other regions, so that the number of counts (of draws) are the same in total.
H = haltonset(2,'Skip',50+1);
H = net(H,3573*3);
H = reshape(H,3573,3,2);
S = norminv(H);
histogram(S(:,3,1),100,'FaceColor','blue','EdgeAlpha',0.5);
hold on
histogram(S(:,3,2),100,'FaceColor','white','EdgeAlpha',0.5);
legend('Standard normal draws for 1st dimension','Standard normal draws for 2nd dimension')
hold off
0 个评论
采纳的回答
the cyclist
2021-10-25
编辑:the cyclist
2021-10-25
If you look carefully, you will notice that your bins are not at precisely the same locations. If you instead choose the exact bin locations (instead of just using 100 bins), you'll get what you expect:
H = haltonset(2,'Skip',50+1);
H = net(H,3573*3);
H = reshape(H,3573,3,2);
S = norminv(H);
binEdges = -4:0.1:4;
histogram(S(:,3,1),binEdges,'FaceColor','blue','EdgeAlpha',0.5);
hold on
histogram(S(:,3,2),binEdges,'FaceColor','white','EdgeAlpha',0.5);
legend('Standard normal draws for 1st dimension','Standard normal draws for 2nd dimension')
hold off
Just illustrate it a bit more, here are the differences in bin counts for your method. You see that away from the peak, the values are negative, so the rear bins are fully hidden behind the front bins.
H = haltonset(2,'Skip',50+1);
H = net(H,3573*3);
H = reshape(H,3573,3,2);
S = norminv(H);
hc1 = histcounts(S(:,3,1),100);
hc2 = histcounts(S(:,3,2),100);
figure
plot(hc1-hc2)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!