In [1]:
%matplotlib notebook
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.stats import norm, chi2


/home/saket/anaconda/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)

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]:
<matplotlib.legend.Legend at 0x7fc70e0bc790>

In [ ]: