# -*- coding: utf-8 -*- """ Created on Mon Feb 09 15:13:03 2015 Listing 14.1 : densité de probabilité pour le chi-deux @author: grivet """ import numpy as np from scipy.special import gamma import matplotlib.pyplot as plt def chi2(x,n): return x**(n/2.0-1)*np.exp(-x/2.0)/(2**(n/2.0)*gamma(n/2.0)) xmax = 20; npt = 200 x = np.linspace(0,xmax,npt) plt.plot(x,chi2(x,5),label = '$n = 3$') plt.plot(x,chi2(x,9),label = '$n = 9$') plt.plot(x,chi2(x,16),label = '$n = 16$') plt.legend()