시작하기무료로 시작하기

통계량 변동 시각화

이전에 표본 통계량의 변동을 계산해 보셨죠. 이제 그 변동을 시각화해 보겠습니다.

미리 로드된 population과, 표본을 추출하고 표본 통계량 배열을 반환하는 사전 정의 함수 get_sample_statistics()를 사용합니다.

여기서는 matplotlibaxis.hist()를 감싼 사전 정의 함수 plot_hist()를 사용합니다. 이 함수는 전달된 배열을 구간화하고 바로 그려 줍니다. 이를 통해 표본 통계량이 단일 값이 아니라 값들의 분포를 가진다는 점을 한눈에 볼 수 있어요.

이 연습은 강의의 일부입니다

Python으로 배우는 선형 모델 입문

강의 보기

연습 안내

  • populationget_sample_statistics()에 전달해 표본 통계량 분포를 가져오세요.
  • 각 통계량 배열에 대해 np.linspace()로 히스토그램 bin 경계를 정의하세요.
  • 사전 정의된 plot_hist()를 두 번 호출해, 통계량 분포 meansdeviations를 각각 별도의 히스토그램으로 그리세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Generate sample distribution and associated statistics
means, stdevs = get_sample_statistics(____, num_samples=100, num_pts=1000)

# Define the binning for the histograms
mean_bins = np.____(97.5, 102.5, 51)
std_bins = np.____(7.5, 12.5, 51)

# Plot the distribution of means, and the distribution of stdevs
fig = plot_hist(data=____, bins=____, data_name="Means", color='green')
fig = plot_hist(data=____, bins=____, data_name="Stdevs", color='red')
코드 편집 및 실행