Erreur relative des estimateurs ponctuels

Échantillonnage en Python

James Chapman

Curriculum Manager, DataCamp

La taille de l'échantillon = nombre de lignes

len(coffee_ratings.sample(n=300))
300
len(coffee_ratings.sample(frac=0.25))
334
Échantillonnage en Python

Tailles d'échantillon variées

coffee_ratings['total_cup_points'].mean()
82.15120328849028
coffee_ratings.sample(n=10)['total_cup_points'].mean()
83.027
coffee_ratings.sample(n=100)['total_cup_points'].mean()
82.4897
coffee_ratings.sample(n=1000)['total_cup_points'].mean()
82.1186
Échantillonnage en Python

Erreurs relatives

Paramètre de population :

population_mean = coffee_ratings['total_cup_points'].mean()

Estimation ponctuelle :

sample_mean = coffee_ratings.sample(n=sample_size)['total_cup_points'].mean()

Erreur relative en pourcentage :

rel_error_pct = 100 * abs(population_mean-sample_mean) / population_mean
Échantillonnage en Python

Erreur relative vs taille d'échantillon

import matplotlib.pyplot as plt
errors.plot(x="sample_size", 
            y="relative_error", 
            kind="line")
plt.show()

Propriétés :

  • Très bruité, surtout pour les petits échantillons
  • Amplitude d'abord forte, puis s'aplatit
  • L'erreur relative diminue jusqu'à zéro (quand taille = population)

Graphique linéaire : erreur relative selon la taille de l'échantillon.

Échantillonnage en Python

Passons à la pratique !

Échantillonnage en Python

Preparing Video For Download...