Comece agoraComece grátis

Visualizando estatísticas de teste

Neste exercício, você vai abordar a hipótese nula comparando a distribuição de uma estatística de teste obtida de duas maneiras diferentes.

Primeiro, você vai examinar duas "populações", agrupadas por tempos iniciais e tardios, e calcular a distribuição da estatística de teste. Depois, embaralhe as duas populações, de modo que os dados não estejam mais ordenados no tempo e cada uma tenha uma mistura de tempos iniciais e tardios, e então recalcule a distribuição da estatística de teste.

Para começar, já carregamos os dois grupos de duração no tempo, group_duration_short e group_duration_long, e duas funções, shuffle_and_split() e plot_test_statistic().

Este exercicio faz parte do curso

Introdução à Modelagem Linear em Python

Ver curso

Instruções do exercicio

  • Use np.random.choice() para reamostrar group_duration_short e group_duration_long, e tire a diferença entre as reamostragens para calcular test_statistic_unshuffled.
  • Use shuffle_and_split() nos group_duration_short e group_duration_long originais (nesta ordem específica) para criar duas novas populações misturadas.
  • Reamostre as populações embaralhadas e subtraia resample_short de resample_long para calcular um novo test_statistic_shuffled.
  • Use plot_test_statistic() para plotar as duas distribuições da estatística de teste e comparar visualmente.

exercicio interativo prático

Tente este exercicio completando este código de exemplo.

# From the unshuffled groups, compute the test statistic distribution
resample_short = np.random.choice(____, size=500, replace=____)
resample_long = np.random.choice(____, size=500, replace=____)
test_statistic_unshuffled = ____ - ____

# Shuffle two populations, cut in half, and recompute the test statistic
shuffled_half1, shuffled_half2 = shuffle_and_split(____, ____)
resample_half1 = np.random.choice(____, size=500, replace=____)
resample_half2 = np.random.choice(____, size=500, replace=____)
test_statistic_shuffled = resample_half2 - resample_half1

# Plot both the unshuffled and shuffled results and compare
fig = plot_test_statistic(____, label='Unshuffled')
fig = plot_test_statistic(____, label='Shuffled')
Editar e Executar Código