Intervalles de confiance bootstrap

Réflexion statistique en Python (partie 2)

Justin Bois

Lecturer at the California Institute of Technology

Fonction de réplique bootstrap

def bootstrap_replicate_1d(data, func):
    """Generate bootstrap replicate of 1D data."""
    bs_sample = np.random.choice(data, len(data))
    return func(bs_sample)

bootstrap_replicate_1d(michelson_speed_of_light, np.mean)
299859.20000000001
bootstrap_replicate_1d(michelson_speed_of_light, np.mean)
299855.70000000001
bootstrap_replicate_1d(michelson_speed_of_light, np.mean)
299850.29999999999
Réflexion statistique en Python (partie 2)

Beaucoup de répliques bootstrap

bs_replicates = np.empty(10000)

for i in range(10000): bs_replicates[i] = bootstrap_replicate_1d( michelson_speed_of_light, np.mean)
Réflexion statistique en Python (partie 2)

Tracer un histogramme des répliques bootstrap

_ = plt.hist(bs_replicates, bins=30, normed=True)
_ = plt.xlabel('mean speed of light (km/s)')
_ = plt.ylabel('PDF')
plt.show()
Réflexion statistique en Python (partie 2)

Estimation bootstrap de la moyenne

ch2-2.011.png

Réflexion statistique en Python (partie 2)

Intervalle de confiance d'une statistique

  • Si l'on répétait les mesures encore et encore, p% des valeurs observées se situeraient dans l'intervalle de confiance à p%.
Réflexion statistique en Python (partie 2)

Intervalle de confiance bootstrap

conf_int = np.percentile(bs_replicates, [2.5, 97.5])
array([ 299837.,  299868.])

ch2-2.016.png

Réflexion statistique en Python (partie 2)

Passons à la pratique !

Réflexion statistique en Python (partie 2)

Preparing Video For Download...