Attention:
Veuillez noter que ce document est en cours de rédaction. Dans son état actuel, il n'est pas destiné à être lu par d'autres personnes que ses auteurs.
Problèmatique: On suppose qu'on a un échantillon et que la loi de probabilité $L_{v}$ qui à généré cet échantillon est inconnue. Comment retrouver cette loi et ses paramètres à partir de l'échantillon dont on dispose ?
où :
$x_i$ | pile | face |
---|---|---|
$n_{ei}$ | 47 | 53 |
$n_{hi}$ | 50 | 50 |
La loi de probabilité à retrouver est une loi binomiale $\mathcal{b}(100, 0.25)$:
n = 100
p = 0.25
$E(X) = np = 25$
$V(X) = np(1-p) = 18.75$
$STD(X) = \sqrt{18.75} \simeq 4.33$
import numpy as np
k = 100 # taille de l'echantillon
echantillon = np.random.binomial(n=n, p=p, size=k)
#np.random.normal(loc=m, scale=sigma, size=k)
%matplotlib inline
import matplotlib.pyplot as plt
plt.hist(echantillon,
bins=np.linspace(echantillon.min(), echantillon.max(), echantillon.max() - echantillon.min() + 1));
plt.hist(echantillon,
bins=np.linspace(echantillon.min(), echantillon.max(), echantillon.max() - echantillon.min() + 1),
cumulative=True);
#print("moyenne:", m)
#print("écart type:", sigma)
print("moyenne empirique de l'échantillon:", echantillon.mean())
print("écart type empirique de l'échantillon:", echantillon.std())
def dist_chi2(x, *param):
n = x[0]
p = x[1]
dist = 0
n_xi = 10 # TODO
for xi in range(n_xi):
n_ei = 0 # TODO
n_hi = 0 # TODO
dist += ((n_ei - n_hi)**2) / n_hi
return dist
from scipy import optimize
n_slice = slice(1., 200., 1.)
p_slice = slice(0.1, 1.0, 0.1)
search_ranges = (n_slice, p_slice)
#res = optimize.brute(dist_chi2,
# search_ranges,
# #args=params,
# full_output=True,
# finish=optimize.fmin)
#print("x* =", res[0])
#print("f(x*) =", res[1])