점추정의 상대 오차

Python으로 살펴보는 표본추출(Sampling)

James Chapman

Curriculum Manager, DataCamp

표본 크기는 행 개수

len(coffee_ratings.sample(n=300))
300
len(coffee_ratings.sample(frac=0.25))
334
Python으로 살펴보는 표본추출(Sampling)

다양한 표본 크기

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
Python으로 살펴보는 표본추출(Sampling)

상대 오차

모집단 모수:

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

점추정값:

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

백분율 상대 오차:

rel_error_pct = 100 * abs(population_mean-sample_mean) / population_mean
Python으로 살펴보는 표본추출(Sampling)

상대 오차 vs. 표본 크기

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

특징:

  • 작은 표본에서 특히 변동이 큼
  • 초반 기울기가 크고 이후 완만해짐
  • 표본 크기=모집단이면 상대 오차는 0에 수렴

표본 크기 대비 상대 오차의 선 그래프.

Python으로 살펴보는 표본추출(Sampling)

연습해 봅시다!

Python으로 살펴보는 표본추출(Sampling)

Preparing Video For Download...