Drawing from Various Truncated Normal Distributions

조회 수: 2 (최근 30일)
Colin Lynch
Colin Lynch 2018년 5월 25일
댓글: Jeff Miller 2018년 5월 26일
Hello there!
I am running several simulations where I need to randomly draw from various kinds of truncated normal distributions. The PDFs of these distributions are shown in the attached file various_truncated_distributions.png. Ideally, when I draw from these distributions, the resulting data will mirror these PDFs. However, when I do this, I get a weird bimodal distribution, as shown in random_draw_test.png which shows the case where mu = 0. The code I used to create this graph is as follows:
pd = makedist('Normal', 'mu', 0,'sigma',.1);
t = truncate(pd,0,1);
x = 0:.01:1;
for i=1:10000
random_number(i) = random(t);
end
[histFreq, histXout] = hist(random_number, 70);
figure;
hold on
bar(histXout, histFreq/sum(histFreq)*100);
plot(x,pdf(t,x),'Color','blue','LineWidth',2);
legend({'Random Draw', 'PDF of Truncated Normal Dist'})
title('Test of Random Draw')
xlabel('Task-Associated Stimulus')
ylabel('Percent')
Am I drawing from this distribution incorrectly, or do I fundamentally misunderstand what it is that I am attempting to do and something like the central limit theorem is skewing my results?
Sincerely, Colin
  댓글 수: 1
Jeff Miller
Jeff Miller 2018년 5월 26일
I cannot replicate your bimodal figure. When I run the code you posted, the histogram looks just like the half-normal density that is plotted.
I wonder if you forgot to clear your random_number array and the upper mode (around .5) was left over from a previous random sample with a different truncated distribution.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by