P Value Method

The P Value Method is the most widely used approach to hypothesis testing in modern statistics and Data Science. Instead of comparing to a critical value, it directly measures how likely your observed data is, assuming the null hypothesis is true.

What a P-Value Means

The p-value is the probability of observing a result as extreme as (or more extreme than) your sample data, assuming the null hypothesis is correct. A small p-value suggests your observed data would be unlikely if the null hypothesis were really true.

Making the Decision

from scipy import stats
import numpy as np

group_a = np.array([22, 25, 21, 24, 23])
group_b = np.array([28, 30, 27, 29, 31])

t_stat, p_value = stats.ttest_ind(group_a, group_b)
print(p_value)

alpha = 0.05   # significance level

if p_value < alpha:
    print("Reject the null hypothesis - result is statistically significant")
else:
    print("Fail to reject the null hypothesis")

Common Significance Levels

0.05 (5%) is the most widely used threshold, though 0.01 and 0.10 are also used depending on how strict the field or decision requires the evidence to be.

A p-value doesn't tell you the probability that the null hypothesis is true, and it doesn't measure the size or practical importance of an effect - it only tells you how surprising your data would be if the null hypothesis held, which is a common and important point of confusion.

Coming Up Next

Next, you'll learn about the types of errors that can occur when making a decision in hypothesis testing.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course