Drawing from Various Truncated Normal Distributions

2 次查看(过去 30 天)
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