Last active
April 28, 2020 10:49
-
-
Save Nick3523/2f7e70ae59ecdf797466ef24908ada41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
get_ipython().run_line_magic('matplotlib', 'inline') | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from math import sqrt, pi, exp | |
import pylab | |
domaine = range(-100,100) | |
mu = 0 | |
sigma = 20 #sigma != 1, donc ce n'est pas un loi normal centrée réduite ! | |
#f est la fonction de répartition de la loi normale. | |
f = lambda x : 1/(sqrt(2*pi*pow(sigma,2))) * exp(-pow((x-mu),2)/(2*pow(sigma,2))) | |
y = [f(x) for x in domaine] | |
plt.title("Courbe en cloche de la loi normale") | |
plt.plot(domaine, y) | |
plt.savefig("Loi-Normale.png",dpi=144) | |
matrice_aleatoire = np.random.rand(10000,10000) #génération d'un échantillion sur une matrice 10000x10000 suivant une loi uniforme | |
sommes = np.sum(matrice_aleatoire,0) #On somme les colonnes | |
plt.hist(sommes, bins=100) | |
plt.title("Simulation de la loi normale") | |
plt.savefig("Simulation-Loi-Normale.png",dpi=144) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment