dimanche 24 juillet 2016

Create smooth, normally distributed variable

Just to start off, I'm aware of numpy's np.random.normal() and np.random.randn() functions. However, I have a code that requires a very accurate normal distribution - small variations from this will cause instabilities due to it's non-linear nature. This is exactly the problem - the numpy functions above are not smoothly distributed, and so ever for N = 30,000 samples, a histogram of the distribution will reveal some nasty patches.

A google search reveals very little, but I was wondering if there was a Python function or module that could be used to create a smooth, normally distributed variable with given mean and variance. Else, is there a simple code that will do this? My knowledge of statistics is not particularly advanced.

EDIT: Using the np.random.normal() function to create four normal distributions yields the plots shown in the image.Here.

Although they may look fairly normally distributed (they are), you can observe that they are not smooth functions. Manual examination of the numbers show that there are differences of ~5-10% from expected values between each bin. This difference is enough to cause instabilities in a non-linear code I am writing.




Aucun commentaire:

Enregistrer un commentaire