How do you design a hypothesis test?

July 24, 2026

Let’s pretend that you are a researcher looking at the effects of a particular drug on blood pressure. You have a suspicion that it has an unintended effect on blood pressure (but you aren’t sure if it raises blood pressure or lowers it).

You’ve run a trial, and have collected some data. The data is a collection of numbers, where each number represents the change in blood pressure of a particular trial participant before and after taking the drug. You reason that if the drug really does have an effect, then the numbers should either all tend to be positive (increase in pressure) or tend to be negative (decrease in pressure). If there is no overall effect, then the numbers should be centred around zero.

You look at your data, and see that some numbers are positive and some are negative, but you are not sure if you see an overall trend. How can you take your data, and quantitatively test your belief on whether the drug has any effect on the blood pressure at all? This is the job of a hypothesis test.

Well, how does one design a hypothesis test when you have questions like this? In this article, I’ll give you a taste of the process by walking through what you might do for our made-up scenario above.

1. Give a form to the generative distribution

The first step in mathematically formalising our question into a hypothesis test is to make some assumptions (educated guesses!) about the underlying probability distribution generating your data. As a way to do this, let’s start to talk about our data and distributions using mathematical symbols.

Let’s say that we have nn data points. We’ll call them x={xi}i=1n\mathbf{x} = \{x_i\}_{i=1}^n. We can imagine that our data is actually a sample from some unknown generative distribution ff. The thinking is that if we can somehow manage to characterise ff, we might glean some insights into the actual process that generated the data (i.e. whether there seems to be a real change in blood pressure).

Where can we start? Well, since our data points are continuous variables resulting from complex biological processes, it might be reasonable to assume that the data is likely distributed according to a normal distribution. If ff is a normal distribution, it can be described by two parameters: its mean and variance. To make our lives simple, let’s assume the true population variance σ2\sigma^2 is already known to us (perhaps from extensive prior biological studies on this drug). That leaves us with one free parameter, the mean, to play around with. We will assign the symbol θ\theta to the mean parameter, so that the probability density function ff can be written as:

f(xθ)=1σ2πe12(xθσ)2 f(x | \theta) = \frac{1}{\sigma \sqrt{2\pi}} e^{ -\frac{1}{2} \left( \frac{x-\theta}{\sigma}\right)^2 }

Now we can start to discuss our hypothesis test in a more precise language. We think that our data x\mathbf{x} comes from a normal distribution like ff. We also think that if the drug really causes increases in blood pressure, our data should be centered around a positive value, which means that θ\theta should be positive, and vice versa (θ<0\theta < 0) if there is a reduction in blood pressure. If there is no effect, then we would expect θ=0\theta = 0. As you can see, our hypothesis test is linked to our belief of what the true value of θ\theta is. More specifically, our null hypothesis (conventionally denoted H0H_0) is that there is no effect, or that θ=0\theta = 0, and our alternative hypothesis (denoted H1H_1) is that there is some effect (either up or down), or that θ0\theta \not = 0.

More formally, we would say that ff is a parametric distribution with one unknown parameter θ\theta. We can then think of ff as being a member of a family of distributions F={fθ:θΘ}\mathcal{F} = \{f_{\theta}: \theta \in \Theta\}, where θ\theta can be anything. We then split the parameter space Θ\Theta into two parts: the null parameter space Θ0\Theta_0, and its complement Θ0c\Theta_0^c. Θ0\Theta_0 consists of values of θ\theta corresponding to the null hypothesis, whereas Θ0c\Theta_0^c corresponds to the alternative hypothesis, and thus usually contains more interesting values of θ\theta. That is, the null hypothesis H0H_0 can now be written as θΘ0\theta \in \Theta_0, and the alternative hypothesis H1H_1 as θΘ0\theta \notin \Theta_0, or θΘ0c\theta \in \Theta_0^c.

To bring it back to our concrete example, our parameter θ\theta is a real number, so Θ=R\Theta = \reals, Θ0={0}\Theta_0 = \{0\} and Θ0c={θ:θR,θ0}\Theta_0^c = \{\theta: \theta \in \reals, \theta \not = 0\}.

Now that we have a mathematical framework for our hypotheses, how can we test our belief on whether the true θ\theta lies inside Θ0\Theta_0 or Θ0c\Theta_0^c, based on the data x\mathbf{x}?

2. Pick a hypothesis testing framework

We need a system where we can use the available data to compute some statistic, then depending on the value of the statistic, either reject H0H_0 or not. There are many strategies/frameworks with which one can come up with a test statistic1, but for this example let’s use the very common and useful likelihood ratio test (LRT). The LRT involves a test statistic λ\lambda of the form:

λ(x)=supθΘ0L(θx)supθΘL(θx) \lambda(\mathbf{x}) = \frac{ \sup_{\theta \in \Theta_0} \mathcal{L}(\theta | \mathbf{x}) }{ \sup_{\theta \in \Theta} \mathcal{L}(\theta | \mathbf{x}) }

Here, L\mathcal{L} signifies the likelihood function. LRTs have a rejection region RXR \subset \mathcal{X} (here X\mathcal{X} is the space of all possible set of nn data points) of the form: R={x:λ(x)c}R = \{\mathbf{x}: \lambda(\mathbf{x}) \leq c\} with cc some constant.

What is the constant cc in the definition of the rejection region? What does it mean, and how do we pick it? Good questions- we will come back to this in a later step below where we pick the desired “size” of our test.

The basic intuition of the LRT is that you are comparing how likely your data x\mathbf{x} would be if θ\theta had to be inside Θ0\Theta_0, versus if θ\theta were allowed to be anything it wanted. If Θ0\Theta_0 contains areas of parameter space that could very well explain x\mathbf{x}, then the numerator will be almost or exactly as big as the denominator. This means λ\lambda will be relatively large and you won’t be able to reject H0H_0. In contrast, let’s say that no θ\theta in Θ0\Theta_0 is very likely to produce x\mathbf{x}. Then λ\lambda might get quite small, and if it is small enough (λ(x)c\lambda(\mathbf{x}) \leq c) you can reject H0H_0.

3. Apply the framework to the problem at hand

Now that we know what the LRT is, and have built some intuition around it, we need to apply it to our problem. Our mystery distribution ff takes the form of a univariate normal with mean θ\theta. So in our case, what is L(θx)\mathcal{L}(\theta | \mathbf{x})?

Well, in general we know that L(θx)=xxf(xθ)\mathcal{L}(\theta | \mathbf{x}) = \prod_{x \in \mathbf{x}}{ f(x | \theta) }. Thus, in our case (remember that x\mathbf{x} is a set of nn samples):

L(θx)=xx1σ2πe12(xθσ)2=(1σ2π)ne12σ2xx(xθ)2 \begin{aligned} \mathcal{L}(\theta | \mathbf{x}) &= \prod_{x \in \mathbf{x}}{ \frac{1}{\sigma \sqrt{2\pi}} e^{ -\frac{1}{2} \left( \frac{x - \theta}{ \sigma } \right)^2} }\\ &= \left(\frac{1}{\sigma \sqrt{2\pi}} \right)^n e^{-\frac{1}{2{\sigma}^2}\sum_{x \in \mathbf{x}}(x - \theta)^2} \end{aligned}

So now we can express L(θx)\mathcal{L}(\theta | \mathbf{x}). We next need to figure out what supθΘ0L(θx)\sup_{\theta \in \Theta_0}\mathcal{L}(\theta | \mathbf{x}) and supθΘL(θx)\sup_{\theta \in \Theta}\mathcal{L}(\theta | \mathbf{x}) are. In our case, the numerator supθΘ0L(θx)\sup_{\theta \in \Theta_0}\mathcal{L}(\theta | \mathbf{x}) of λ\lambda is trivial, since Θ0={0}\Theta_0 = \{0\} and thus supθΘ0L(θx)=L(0x)\sup_{\theta \in \Theta_0}\mathcal{L}(\theta | \mathbf{x}) = \mathcal{L}(0|\mathbf{x}).

For supθΘL(θx)\sup_{\theta \in \Theta}\mathcal{L}(\theta | \mathbf{x}), we need to do a bit of optimisation work as shown below, since Θ\Theta is not a singleton set. For a bit of terminology, the θ\theta we are looking for here where the likelihood function is maximised, is called the maximum likelihood estimate (MLE) of θ\theta given x\mathbf{x}.

To work out the MLE of θ\theta for a univariate normal, we can set ddθL(θx)=0\frac{d}{d\theta}\mathcal{L}(\theta|\mathbf{x}) = 0.

ddθL(θx)=L(θx)σ2xx(xθ) \frac{d}{d\theta} \mathcal{L}(\theta | \mathbf{x}) = \frac{\mathcal{L}(\theta | \mathbf{x})}{{\sigma}^2} \sum_{x \in \mathbf{x}}(x - \theta)

Since L(θx)σ2\frac{\mathcal{L}(\theta | \mathbf{x})}{{\sigma}^2} can never equal zero,

ddθL(θx)=0    xx(xθ)=0    θ=1nxxx=xˉ \begin{aligned} \frac{d}{d\theta} \mathcal{L}(\theta | \mathbf{x}) = 0 &\iff \sum_{x \in \mathbf{x}}(x - \theta) = 0\\ &\iff \theta = \frac{1}{n}\sum_{x \in \mathbf{x}}x = \bar{x} \end{aligned}

As such the MLE for θ\theta here is the arithmetic average over x\mathbf{x}, denoted here as xˉ\bar{x}. Therefore, supθΘL(θx)=L(xˉx)\sup_{\theta \in \Theta}\mathcal{L}(\theta | \mathbf{x}) = \mathcal{L}(\bar{x} | \mathbf{x}).

Putting all of this together, you get:

λ(x)=L(0x)L(xˉx)=exp[12σ2(xx(xxˉ)2xxx2)]=exp[12σ2(2xˉxxx+xxxˉ2)]=exp[nxˉ22σ2] \begin{aligned} \lambda(\mathbf{x}) &= \frac{\mathcal{L}(0 | \mathbf{x})}{\mathcal{L}(\bar{x} | \mathbf{x})}\\ &= \exp\left[{\frac{1}{2{\sigma}^2}\left(\sum_{x \in \mathbf{x}}(x-\bar{x})^2 - \sum_{x \in \mathbf{x}}x^2\right)}\right]\\ &= \exp\left[{\frac{1}{2{\sigma}^2}\left(-2\bar{x}\sum_{x \in \mathbf{x}}x + \sum_{x \in \mathbf{x}}\bar{x}^2 \right)}\right]\\ &= \exp\left[\frac{-n\bar{x}^2}{2{\sigma}^2}\right]\\ \end{aligned}

We can now identify the rejection region RR within our sample space X\mathcal{X} as:

R={x:λ(x)c}={x:exp[nxˉ22σ2]c}={x:xˉ2σ2logcn} \begin{aligned} R &= \{\mathbf{x}: \lambda(\mathbf{x}) \leq c\}\\ &= \left\{\mathbf{x}: \exp\left[\frac{-n\bar{x}^2}{2{\sigma}^2}\right] \leq c\right\}\\ &= \left\{\mathbf{x}: |\bar{x}| \geq \sqrt{\frac{-2{\sigma}^2\log{c}}{n}}\right\} \end{aligned}

4. Pick a size for your test

Where are we now? Well, we have a well-defined test statistic λ\lambda that in our case partitioned the sample space into rejection region RR and its complement. But you might notice that the exact boundaries of our rejection region still depends on a variable that we so far have not yet set explicitly: cc. Earlier I promised that we would discuss what cc means and how we pick it. We will do so here.

In statistics, a useful way to categorise the calibre of hypothesis tests is by reporting its “size”, or sometimes “level”. The intuition behind the meaning of a test with size α\alpha is a test where, if H0H_0 were true (the value of θ\theta were to lie inside of Θ0\Theta_0), the maximum probability of a type 1 error (wrongly rejecting the null hypothesis) is α\alpha.

What is meant by the “maximum probability”? Well, remember that Θ0\Theta_0 can contain many different possible values for θ\theta. Some values of θ\theta within Θ0\Theta_0 may produce distributions that look nothing like ones that could arise if θΘ0c\theta \in \Theta_0^c. If the true θ\theta were to be such a value, then there is a good chance that the data also looks decisively “null-like”. In situations like that, the probability of wrongly rejecting H0H_0 should be very small. Now imagine picking a θ\theta out of Θ0\Theta_0 such that you pick the θ\theta that most closely resembles a θ\theta outside of Θ0\Theta_0. Maybe this θ\theta sits right on the boundary between Θ0\Theta_0 and Θ0c\Theta_0^c. If this was the true value for θ\theta, then unless you have a lot of data, the evidence might sometimes accidentally look like it comes from a distribution with θΘ0c\theta \in \Theta_0^c, simply due to chance. Therefore, the probability of a type 1 error should be higher. In a size α\alpha test, the probability of a type 1 error in the worst case scenario- where the true θΘ0\theta \in \Theta_0 is the one that most looks like a non-null θ\theta - is equal to α\alpha. That’s what I meant by the “maximum probability” of a type 1 error.

The more succinct and technical definition would be that a hypothesis test of size α\alpha is a hypothesis test whose power function has a maximum value of α\alpha when evaluated within Θ0\Theta_0.

If you have worked in biology or medicine, you often hear about data showing “statistical significance” with a “pp value less than 0.05”. You may also remember being taught the meaning of a pp value being less than 0.05. That is, if there is no real signal (e.g. no real difference between two groups of data), then the probability of seeing a signal as large as or larger than what the data shows is less than 0.05. Well, now that you’ve been introduced to some statistics jargon, you can equivalently say that such hypothesis tests have a size or level (α\alpha) of 0.05. Another way of thinking about this is that α\alpha is basically a threshold such that if the pp value is less than α\alpha, you reject the null hypothesis.

With this in mind, let’s say that we want our hypothesis test to be of size 0.05. That is, a maximum type 1 error probability of 5%. We can calibrate our cc threshold such that if θΘ0\theta \in \Theta_0, the maximum probability that the data xR\mathbf{x} \in R is 5%.

In our case, Θ0\Theta_0 only contains 0, so there is no need to do any optimisation.

supθΘ0P(xRθ)=Pθ=0(xR)=Pθ=0(xˉ2σ2logcn)=Pθ=0(nσxˉ2logc) \begin{aligned} \sup_{\theta \in \Theta_0}P(\mathbf{x} \in R | \theta) &= P_{\theta=0}(\mathbf{x} \in R)\\ &= P_{\theta = 0}\left( |\bar{x}| \geq \sqrt{\frac{-2{\sigma}^2\log{c}}{n}} \right)\\ &= P_{\theta = 0}\left( \frac{\sqrt{n}}{{\sigma}}|\bar{x}| \geq \sqrt{-2\log{c}} \right) \end{aligned}

Since nσ(xˉθ)N(0,1)\frac{\sqrt{n}}{{\sigma}}(\bar{x} - \theta) \sim \mathcal{N}(0,1) (the sample mean of normal random variables is normal), and θ=0\theta = 0:

Pθ=0(nσxˉ2logc)=2×P(Z2logc)P_{\theta = 0}\left( \frac{\sqrt{n}}{{\sigma}}|\bar{x}| \geq \sqrt{-2\log{c}} \right) = 2 \times P(Z \geq \sqrt{-2\log{c}})

Where ZN(0,1)Z \sim \mathcal{N}(0,1). Now we want this probability to be 0.05, or 120\frac{1}{20}. Let zαz_{\alpha} denote the critical point such that P(Zzα)=αP(Z \geq z_{\alpha}) = \alpha. Then:

2×P(Z2logc)=120    P(Z2logc)=140    2logc=z140    c=exp(z1402/2)0.146 \begin{aligned} 2 \times P(Z \geq \sqrt{-2\log{c}}) &= \frac{1}{20}\\ \iff P(Z \geq \sqrt{-2\log{c}}) &= \frac{1}{40}\\ \iff \sqrt{-2\log{c}} &= z_{\frac{1}{40}}\\ \iff c &= \exp\left(-z_{\frac{1}{40}}^2 / 2\right) \approx 0.146 \end{aligned}

Et voila! We now have our threshold cc, calibrated so that our test is of size 0.05. Armed with this cc, all you have left to do is to check whether the following is true:

xˉ2σ2logcn|\bar{x}| \geq \sqrt{\frac{-2{\sigma}^2\log{c}}{n}}

If yes, then according to our test design and assumptions, you can reject H0H_0. If not, then you cannot reject H0H_0.


  1. The LRT framework chosen for this article is an example of a frequentist test framework. Other examples of frequentist frameworks include the Wald test and score test. Of course, there is an entire world of Bayesian inference out there as well, but this is all a bit outside the scope of this article. ↩︎