# How to plot the normal distribution?

According to 'An Introduction to Probability Theory and Its Applications', Vol. 1 by Feller the number of inversions in a random permutations at large numbers satisfy CLT with dedicated mean and variance.

However, I am practically intrested in how to plot the figure of the normal distribution (what to calculate for it)?

I understand that the figure may depends on the fact of how large the numbers are. Any explanations to clarify the topic are highly welcomed. Thank you in advance.

• Do you want to plot the PDF $\frac{1}{\sigma\sqrt{2\pi}}\exp-\frac{(x-\mu)^2}{2\sigma^2}$ or the CDF $\frac{1}{2}\left[1+\operatorname{erf}\left(\frac{x-\mu}{\sigma\sqrt{2}}\right)\right]$? Either way, the case $\mu=0,,\sigma=1$ is worth using for definiteness. – J.G. Dec 20 '18 at 19:52
• The PDF one, which depends on the number of elements – Mikhail Gaichenkov Dec 20 '18 at 20:06

Here is how to plot the density function of $$N(0,1)$$: $$f(x) = \frac{e^{-\frac{x^2}{2}}}{\sqrt{2 \pi}} .$$

In Mathematica, a one-liner:

Plot[PDF[NormalDistribution[], x], {x, -4, 4}]


In Python, slightly more verbose:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 101)
y = np.exp(-x*x/2) / np.sqrt(2*np.pi)

plt.plot(x, y)
plt.show()


• Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements? – Mikhail Gaichenkov Dec 20 '18 at 19:56
• Translate and rescale: if $Z\sim N(\mu,\sigma)$, then $(Z-\mu)/\sigma\sim N(0,1)$. – Federico Dec 20 '18 at 19:58
• Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000? – Mikhail Gaichenkov Dec 20 '18 at 20:04
• They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change – Federico Dec 20 '18 at 20:08