how do i create random normally distributed number array within a set range?
Ältere Kommentare anzeigen
i want to create an array of 2000 values that are within the range [-5 5] and are normally distributed around 0?
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 17 Feb. 2017
pd = makedist('Normal');
t = truncate(pd, -5, 5);
r = random(t,2000,1);
Warning: the probabilities of a truncated normal distribution do not add up to 1.0 !!
2 Kommentare
James Tursa
am 18 Feb. 2017
Bearbeitet: James Tursa
am 18 Feb. 2017
doc on truncate indicates that the pdf of the output is re-normalized based on the original probability assigned to the interval, so that the probabilities of the result would in fact add up to 1.0, and the example given for the truncated normal seems to verify this. I.e., the probabilities assigned to the interval in question are scaled up slightly using the amount clipped off of the tails so that the result is a pdf.
Walter Roberson
am 18 Feb. 2017
Ah, I never noticed that before.
Kategorien
Mehr zu Descriptive Statistics and Visualization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
