How do I generate a random number with normal distribution
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jamie Derulo
am 30 Mär. 2019
Kommentiert: Star Strider
am 30 Mär. 2019
I want to generate a random matrix with normal distribution between -10 and 10. I cannot use randn() because it has no boundaries. Is there any other to generate such matrix??
0 Kommentare
Akzeptierte Antwort
Star Strider
am 30 Mär. 2019
This is called a truncated distribution. While you are correct that it is no longer strictly a normal distribution (that extends to infinity to either side of the mean), you can nevertheless define it. The extended discussion is in the truncate (link) documentation section in Truncate a Probability Distribution (link).
For your Question, this would be:
pd = makedist('Normal')
t = truncate(pd,-10,10)
r = random(t,10000,1);
Experiment to get the result you want.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!