Simple exemple sur comment tracer une loi normale asymétrique avec python et matplotlib (source)
[image:normal-skewed-distribution]
from scipy import linspacefrom scipy import pi,sqrt,expfrom scipy.special import erfimport matplotlib.pyplot as pltdef pdf(x):return 1/sqrt(2*pi) * exp(-x**2/2)def cdf(x):return (1 + erf(x/sqrt(2))) / 2def skew(x,e=0,w=1,a=0):t = (x-e) / wreturn 2 / w * pdf(t) * cdf(a*t)# You can of course use the scipy.stats.norm versions# return 2 * norm.pdf(t) * norm.cdf(a*t)x = linspace(0,30,100)e = 5.0 # locationw = 6.0 # scalea = 10p = skew(x,e,w,a)plt.plot(x,p)plt.scatter(x,p)plt.title('Loi normale asymetrique')plt.grid()plt.xlim(0,30)plt.savefig('normal_skewed_distribution.png',bbox_inches='tight')plt.show()
Recherches associées
| Liens | Site |
|---|---|
| skew normal distribution in scipy | stackoverflow |
| Skew normal distribution | wikipedia |
| Loi normale asymétrique | wikipedia |
