Comece agoraComece grátis

Visualizando o valor de p

Neste exercício, você vai visualizar o valor de p, a chance de que o efeito (ou "velocidade") que estimamos seja resultado de variação aleatória na amostra. Seu objetivo é visualizar isso como a fração de pontos na distribuição do teste embaralhado que ficam à direita da média do teste estatístico ("tamanho do efeito") calculado a partir das amostras não embaralhadas.

Para começar, já carregamos group_duration_short e group_duration_long e as funções compute_test_statistic(), shuffle_and_split() e plot_test_statistic_effect()

Este exercicio faz parte do curso

Introdução à Modelagem Linear em Python

Ver curso

Instruções do exercicio

  • Use compute_test_statistic() para obter test_statistic_unshuffled a partir de group_duration_short e group_duration_long; depois use np.mean() para calcular o tamanho do efeito.
  • Use shuffle_and_split() para criar shuffle_half1 e shuffle_half2, e use compute_test_statistic() para calcular test_statistic_shuffled.
  • Crie uma máscara booleana condition em que os valores de test_statistic_shuffled sejam maiores ou iguais a effect_size, depois use essa máscara para calcular o p_value.
  • Imprima o p_value e plote ambos os testes estatísticos usando plot_test_statistic_effect().

exercicio interativo prático

Tente este exercicio completando este código de exemplo.

# Compute the test stat distribution and effect size for two population groups
test_statistic_unshuffled = compute_test_statistic(____, ____)
effect_size = np.mean(____)

# Randomize the two populations, and recompute the test stat distribution
shuffled_half1, ____ = shuffle_and_split(group_duration_short, ____)
test_statistic_shuffled = compute_test_statistic(shuffled_half1, ____)

# Compute the p-value as the proportion of shuffled test stat values >= the effect size
condition = ____ >= ____
p_value = len(test_statistic_shuffled[____]) / len(test_statistic_shuffled)

# Print p-value and overplot the shuffled and unshuffled test statistic distributions
print("The p-value is = {}".format(____))
fig = plot_test_stats_and_pvalue(test_statistic_unshuffled, test_statistic_shuffled)
Editar e Executar Código