# Hypothesis Testing and p-values

> Using significance tests to judge whether an observed difference is likely real, and avoiding the common misreadings. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/data-analyst/hypothesis-testing
Last updated: 2026-11-28

Using significance tests to judge whether an observed difference is likely real, and avoiding the common misreadings.

Intermediate · about 6 hours · difficulty 3/5

Learn first: [Estimation and Confidence Intervals](https://www.internhack.in/roadmaps/tracks/data-analyst/confidence-intervals)

Hypothesis testing asks: if there were really no difference, how surprising would our data be?

### The mechanics

1. State a **null hypothesis** (no difference) and an **alternative**.
2. Choose a significance level, often 0.05.
3. Compute a test statistic and its **p-value**: the probability of seeing a result at least this extreme if the null were true.
4. If p is below the threshold, reject the null; otherwise, you failed to find evidence (which is not proof of no effect).

### Choosing a test

- Compare two means: **t-test** (Welch's version by default).
- Compare two proportions: **two-proportion z-test** or **chi-square test**.
- Relationship between two categorical variables: **chi-square test of independence**.
- Skewed data, small samples: **Mann-Whitney U** or bootstrap.
- More than two groups: **ANOVA**, then pairwise comparisons.

### Errors and power

- **Type I error**: false positive. **Type II error**: missed a real effect.
- **Power** is the chance of detecting an effect of a given size; it depends on sample size and noise.
- **Practical significance** matters more than statistical significance: a 0.01% lift can be "significant" with millions of rows yet worthless.

**Pitfalls:** testing many metrics or segments and reporting the one that hit p < 0.05 (multiple comparisons), and reading p as "probability the null is true". Move on when you can pick a test for a scenario and explain its result to a non-technical colleague in two sentences.

## Key concepts

- **Null and alternative hypotheses**
- **p-values and significance levels**
- **t-tests**
- **Chi-square and proportion tests**
- **Non-parametric tests**
- **Type I and II errors, power**
- **Multiple comparisons**
- **Practical vs statistical significance**
- **ANOVA**

## Mini project

Using the Kaggle 'Students Performance in Exams' dataset, test whether test-preparation course completion is associated with higher maths scores, and report effect size alongside the p-value.

## Check yourself

A p-value of 0.03: what does it tell you, and what does it NOT tell you?

## Free resources

- [OpenIntro Statistics](https://www.openintro.org/book/os/) (OpenIntro)
- [Statistics and probability](https://www.khanacademy.org/math/statistics-probability) (Khan Academy)
- [statsmodels documentation](https://www.statsmodels.org/stable/index.html) (statsmodels)

Previous: [Estimation and Confidence Intervals](https://www.internhack.in/roadmaps/tracks/data-analyst/confidence-intervals) · Next: [Correlation, Causation and Confounding](https://www.internhack.in/roadmaps/tracks/data-analyst/correlation-causation)

## More in Statistical Thinking for Decisions

- [Descriptive Statistics](https://www.internhack.in/roadmaps/tracks/data-analyst/descriptive-statistics)
- [Probability and Distributions](https://www.internhack.in/roadmaps/tracks/data-analyst/probability-distributions)
- [Sampling, Bias and Data Collection](https://www.internhack.in/roadmaps/tracks/data-analyst/sampling-and-bias)
- [Estimation and Confidence Intervals](https://www.internhack.in/roadmaps/tracks/data-analyst/confidence-intervals)
- [Hypothesis Testing and p-values](https://www.internhack.in/roadmaps/tracks/data-analyst/hypothesis-testing)
- [Correlation, Causation and Confounding](https://www.internhack.in/roadmaps/tracks/data-analyst/correlation-causation)
- [Linear and Logistic Regression for Analysts](https://www.internhack.in/roadmaps/tracks/data-analyst/regression-basics)
- [A/B Testing and Experiment Design](https://www.internhack.in/roadmaps/tracks/data-analyst/ab-testing)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Analyst Roadmap](https://www.internhack.in/roadmaps/tracks/data-analyst)
