liveBook · Manning

Null hypothesis

As explained in Statistics Every Programmer Needs

A null hypothesis is a specified default claim about a population or data-generating process that a hypothesis test evaluates evidence against.

A null hypothesis is the claim a statistical test evaluates against observed data. State it before interpreting a result: it might say that predictors have no effect, or that observed counts follow a specified distribution. A p-value measures how unusual the result would be if that claim were true; it is not the probability that the claim is true. section 4.2.1 section 4.2.3 section 12.5.1

Choose a significance threshold in advance. At the commonly used 5% level, reject the null hypothesis when p < 0.05; otherwise, fail to reject it. The threshold is a convention, not a universal boundary. Failing to reject means the test has not supplied sufficient evidence against the claim—it does not establish that the claim is true. section 4.2.1 section 12.5.1

The claim depends on the test and the decision at hand:

  • In linear regression, the overall null hypothesis sets every predictor coefficient, but not the intercept, to zero. Use the F-statistic’s associated p-value to decide whether to reject it; rejection indicates that at least one predictor has a statistically significant effect. section 4.2.3
  • In logistic regression, the model-level null hypothesis says the predictors do not help distinguish classes. Its log-likelihood-ratio p-value tests that overall claim; individual predictor p-values answer narrower questions. section 5.2.2
  • In a chi-square comparison of leading digits, the null hypothesis says the counts follow a Benford distribution. Compare observed counts with counts expected under that distribution. section 12.5.1

A regression decision

For a linear model relating runners’ stage 1 and stage 2 times, the F-statistic’s p-value is 0.000107. Because it is below 0.05, reject the claim that the predictor coefficient is zero. This establishes statistical significance for the modeled association, not that the model explains every difference in stage 2 times. section 4.2.3

>>> import scipy.stats as stats
>>> x2 = stats.chisquare(bf_populations.Counts, 
>>>                      bf_populations.Expected_Counts)
>>> print(x2)
Power_divergenceResult(statistic=7.192526063677557, pvalue=0.5160103482305225)

The chi-square result pairs a test statistic of about 7.193 with p = 0.516. At a 5% threshold, fail to reject the claim that the population counts’ leading digits follow Benford’s distribution. section 12.5.1

How Statistics Every Programmer Needs covers it

How deep it goes
Defines test-specific claims and interprets p-values against a chosen threshold, without developing a general theory of hypothesis testing.
Examples
Uses running-time regression, raisin classification, and Benford leading-digit counts to give distinct null claims.
What it assumes
Introduces statistical tests and p-values directly while using predictor coefficients, distributions, and observed versus expected counts in applications.
What you can do after
Apply it via regression or chi-square p-values to decide whether to reject a stated claim at a predetermined threshold.
How it connects
Links p-values and significance levels to F-tests, logistic regression likelihood-ratio tests, and chi-square tests.

Also explained in

Compare how 4 books explain null hypothesis →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.