Histogram of overlaid standard normal draws

1 回表示 (過去 30 日間)
Snoopy
Snoopy 2021 年 10 月 24 日
コメント済み: Snoopy 2021 年 10 月 26 日
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

採用された回答

the cyclist
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)
  1 件のコメント
Snoopy
Snoopy 2021 年 10 月 26 日
Thanks for the comprehensive and clear answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBiotech and Pharmaceutical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by