Calculer Cov(x,y)\mathrm{Cov}(x,y)Cov(x,y) et ρ(x,y)\rho(x,y)ρ(x,y) à partir de deux tableaux numpy en utilisant np.cov et np.corrcoef.
np.cov
np.corrcoef
Choisissez une approche :
En calculant np.cov(x, y, ddof=0)[0,1] et np.corrcoef(x, y)[0,1], puis en vérifiant à la main
np.cov(x, y, ddof=0)[0,1]
np.corrcoef(x, y)[0,1]
Utiliser les fonctions numpy pour obtenir covariance et coefficient de corrélation empiriques, et comparer aux formules Cov(x,y)=1n∑(xi−xˉ)(yi−yˉ)\mathrm{Cov}(x,y)=\tfrac{1}{n}\sum(x_i-\bar x)(y_i-\bar y)Cov(x,y)=n1∑(xi−xˉ)(yi−yˉ) et ρ=Cov/(σxσy)\rho=\mathrm{Cov}/(\sigma_x\sigma_y)ρ=Cov/(σxσy).