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.

  • $\begingroup$ 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. $\endgroup$ – J.G. Dec 20 '18 at 19:52
  • $\begingroup$ The PDF one, which depends on the number of elements $\endgroup$ – 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}]

enter image description here

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)

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.