Generating a number range with normal spacing density¶

We want to generate N numbers between x_min and x_max with both limits included. This is trivial to do with a uniform distribution, for example with np.linspace(x_min, x_max, N) in NumPy.

But sometimes it can be helpful to have a range of numbers that are more concentrated around a specific area. For example if they are used as input for monte-carlo simulations. Ideally their density would be proportional to a normal distribution. That shall be the goal of this notebook! Source is on github.

We'll assume a normal definition with a standard deviation of $\sigma$ and a center of $\mu$:

$$f(x) = \frac{1}{\sigma \sqrt{2\pi}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)$$

Let's have a look: