Drawing from Various Truncated Normal Distributions
1 view (last 30 days)
Show older comments
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 Comment
Jeff Miller
on 26 May 2018
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.
Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!