In [1]:
%matplotlib notebook
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.stats import norm, chi2
In [2]:
X = np.random.normal(loc=0, scale=1, size=1000)
Y = np.random.normal(loc=0, scale=1, size=1000)
Chi2 = np.random.chisquare(2, 1000)
In [6]:
fig, ax = plt.subplots(1, 1)
ax.hist(X**2+Y**2, normed=True, histtype='stepfilled', label=r'$X^2+Y^2$')
x = np.linspace(-5,15, 1000)
rv = chi2(2)
ax.plot(x, rv.pdf(x), 'r-', lw=2, label=r'$\chi^2$', alpha=0.5)
ax.legend(loc='best', frameon=False)
Out[6]:
In [ ]: