시작하기무료로 시작하기

귀무가설

이 연습 문제에서는 귀무가설을 다음과 같이 설정합니다.

짧은 시간과 긴 시간의 차이는 총 이동 거리에는 영향을 주지 않는다.

여기서 "영향이 0"이라는 뜻은, 짧은 시간과 긴 시간의 표본을 서로 섞어 두 개의 새로운 표본 각각이 짧은/긴 이동이 섞이도록 만든 뒤 검정 통계를 계산하면, 평균적으로 그 값이 0이 된다는 의미로 해석합니다.

이번 과제의 목표는 셔플링과 리샘플링을 수행하는 것입니다. 셔플링되지 않은 시간 구간 집단인 group_duration_shortgroup_duration_long부터 시작하세요.

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

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

강의 보기

연습 안내

  • np.concatenate()로 두 모집단을 합친 다음, 그 컨테이너 안의 값을 np.random.shuffle()로 셔플하세요.
  • shuffle_bucket을 반으로 슬라이스하고, 각 shuffle_half에 대해 np.random.choice()로 리샘플하세요.
  • test_statisticresample_half2에서 resample_half1을 뺀 값으로 계산하세요.
  • effect_sizetest_statisticnp.mean()으로 계산하고, 결과를 출력하세요.

실습형 인터랙티브 연습

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

# Shuffle the time-ordered distances, then slice the result into two populations.
shuffle_bucket = np.____((group_duration_short, group_duration_long))
np.random.shuffle(____)
slice_index = len(shuffle_bucket)//2
shuffled_half1 = shuffle_bucket[0:____]
shuffled_half2 = shuffle_bucket[____:]

# Create new samples from each shuffled population, and compute the test statistic
resample_half1 = np.random.choice(____, size=500, replace=____)
resample_half2 = np.random.choice(____, size=500, replace=____)
test_statistic = ____ - ____

# Compute and print the effect size
effect_size = np.mean(____)
print('Test Statistic, after shuffling, mean = {}'.format(____))
코드 편집 및 실행