How to generate random numbers in a Gaussian distribution?
Show older comments
Given A = 1 and B = 5, and knowing that the mean is 2.5 and the standard deviation is 1, I want to generate 1000 random points between A and B using a normal (Gaussian) distribution. I am unsure how to do this in MATLAB efficienctly.
6 Comments
John D'Errico
on 7 Feb 2023
They are not normally distributed if they are bounded as you want. You COULD use a truncated normal distribution however.
help truncate
Ali Almakhmari
on 7 Feb 2023
Edited: Ali Almakhmari
on 7 Feb 2023
Voss
on 7 Feb 2023
If they are not bounded, you can use randn:
Ali Almakhmari
on 7 Feb 2023
Edited: Ali Almakhmari
on 7 Feb 2023
Walter Roberson
on 7 Feb 2023
values = mean + randn(1000,1) * sigma;
The repmat() is valid, but slower than needed for this purpose.
Ali Almakhmari
on 7 Feb 2023
Accepted Answer
More Answers (0)
Categories
Find more on Random Number Generation 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!