Normally distributed Random numbers generator issue
21 views (last 30 days)
I've used the randn function (setting rng(1)) and plotted the histogram:
the result I've got in Matlab 2020b was rather far from a normal distribution.
Increasing the amount of generated numbers helps a bit - but not enough.
Any ideas on how to get a more adequate, normally distributed, bumbers ?
Jan on 24 Mar 2021
Edited: Jan on 24 Mar 2021
This is a perfect normal distribution of 500 values. With such a small set of data, a lot of noise is expected. Otherwise it would not be a random normal distribution.
So the only problem is, that you expect something else, which does not match the defition of normally distributed randomness.
So what do you need? Do you want a perfect normal distribution without randomness, e.g. by just shuffling the values?
Jeff Miller on 24 Mar 2021
As the other posters have said, you aren't necessarily going to get an exactly normal-looking distribution if you generate the numbers randomly. But you can nonrandomly generate an exactly normal-looking set of numbers like this:
nPoints = 500;
cdfvals = (0.5:1:nPoints) / nPoints;
evenRand = norminv(cdfvals);