Histogram of overlaid standard normal draws

조회 수: 3 (최근 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 CenterFile Exchange에서 Biotech and Pharmaceutical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by