표본평균은 정규분포를 따릅니다
이전 연습 문제에서는 이항분포를 따르는 모수를 생성하고, 그 모수에서 임의로 20개의 표본을 뽑아 표본평균을 계산했어요. 이제는 다른 확률분포에서도 표본평균의 모양이 어떻게 나오는지 확인해 보겠습니다.
scipy.stats 라이브러리에서 poisson과 geom 객체, 그리고 describe() 함수를 불러왔습니다. 또한 matplotlib.pyplot은 plt로, numpy는 np로 임포트해 두었습니다.
보시다시피, 표본이 서로 다른 분포에서 생성되더라도 평균들의 분포 모양은 동일하게 나타납니다.
이 연습은 강의의 일부입니다
Python으로 배우는 확률 기초
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Generate the population
population = geom.rvs(p=0.5, size=1000)
# Create list for sample means
sample_means = []
for _ in range(3000):
# Take 20 values from the population
sample = np.random.choice(population, ____)
# Calculate the sample mean
sample_means.append(describe(____).____)
# Plot the histogram
plt.____(sample_means)
plt.show()