Chi distribution

When studying a multi-dimensional random variable, if these are guassian the norm if the vector follows a $\chi$ distribution (see http://en.m.wikipedia.org/wiki/Chi_distribution).

In :
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np


This is important when one considers for instance a 2D vector which is normally distributed:

In :
N = 1e3
x = np.random.randn(2, N)

In :
_ = plt.scatter(x, x) In :
d = np.sqrt(x**2+x**2)

In :
hist, bins, _ = plt.hist(d, 20) This should be well fitted with the $\chi$-dstribution with n=2

In :
p = bins * np.exp(- bins**2 / 2)
plt.bar(bins[:-1], hist/hist.sum(), width=bins-bins)
plt.plot(bins, p/p.sum(), 'r')

Out:
[<matplotlib.lines.Line2D at 0x112d81790>] Hurray! Other visualizations for this distribution:

In :
_ = plt.semilogy(bins, p/p.sum()) In :
_ = plt.semilogx(bins, p/p.sum()) Comparison to other distirbutions

In :
_ = plt.loglog(bins, bins, 'r--', label='lin')
_ = plt.loglog(bins, np.exp(- bins**2 / 2), 'g--', label='gaussian')
_ = plt.loglog(bins, np.exp(- np.log(bins)**2 / 2), 'r--', label='log-gaussian')
_ = plt.loglog(bins, (bins+.1)**-2, 'b--', label='power-law')
_ = plt.loglog(bins, p, label=r'$\chi$')
_ = plt.legend(loc='lower center' ) In :
plt.legend?

In [ ]: