Generating perfect random gaussian numbers

I tried to generate the series of random numbers with gaussian distribution. So, I used numpy.random.normal(mean,standard deviation,size). However, when I converted these numbers into probabability density function using numpy.histogram, this was not same as Gaussian distribution with same mean and standard deviation made by matplotlib.mlab.normpdf.

I understand it may be because numpy.random.normal is random sampling. So, the PDF of these numbers can't be perfectly Gaussian.

Would you please give any advice about how to get the series of random numbers with mean and standard deviation which would have a Gaussian PDF, if it is possible? The size of the numbers which I tried to get is 660.

I will really appreciate any advice and help.

Best regards,



Well, you could "z-score" the sample, by subtracting the sample mean and then dividing by the sample standard deviation:

x = np.random.normal(0, 1, size=660)
x = (x - x.mean()) / x.std()

That will make your vector have a mean of 0 and a standard deviation of 1. But that doesn't mean you will have "perfectly gaussian random numbers." I don't think that's really a concept that makes sense.

It would be helpful to know what application you want to use this for, maybe then it would be easier to suggest alternatives.

Need Your Help

XClass in TYPO3 6.2

php typo3 typoscript

Now I am using TYPO3 6.2beta5 version and in that website I need to include an XClass for the extension sr_feuser_register. Its a "PI_Base" extension and I tried the following methods to include XC...

Heuristic function for applying A* sudoku

algorithm artificial-intelligence heuristics

I need a good heuristic function for A star for sudoku solving.