I want to use bootstrap hypothesis testing to test if the mean of 1 distribution is greater than the other. With no other assumptions on the two distributions (e.g., they don't need to be gaussian).

I found this paragraph in the wikipedia article: https://en.wikipedia.org/wiki/Bootstrapping_(statistics)#Bootstrap_hypothesis_testing

I have two questions:

  1. Is the algorithm indicated in the link above testing for the hypothesis -- "the mean of X is greater than the mean of Y"? i.e., the null hypothesis being "the mean of X is not greater than the mean of Y". If it's not testing for this, how can we test for this?
  1. What is Step 2 doing?

I'm rather confused at this:

Create two new data sets whose values are: 
x_i^' = x_i - X + Z and 
y_i^' = y_i - Y + Z 
where Z is the mean of the combined sample.

At a high level, this seems to be "normalizing" samples with the joint mean. Why is this needed?


2 Answers 2


The null hypothesis is that the means of two distributions are the same. By subtracting the sample mean then adding the combined mean, both distributions now have the same mean (Z).

You can read more here:

Two methods of using bootstraping to test the difference between two sample means

Why shift the mean of a bootstrap distribution when conducting a hypothesis test?

  • $\begingroup$ Thanks, that cleared things up. Do you have some reading material or reference for testing the hypothesis -- "the mean of X is greater than the mean of Y"? $\endgroup$
    – Josh
    Commented Sep 2, 2021 at 21:37
  • $\begingroup$ @Josh It looks like the algorithm you linked to on wikipedia is already testing that one-sided alternative. The test statistic $t$ is signed (the numerator is just $\bar{x}-\bar{y}$ without an absolute value) and the p-value calculation simply has the proportion of resampled cases where $t^*\geq t$, yielding a one-tailed p-value which will tend to be small when the x-mean is considerably larger than the y-mean. $\endgroup$
    – Glen_b
    Commented Sep 3, 2021 at 2:26
  • $\begingroup$ @Josh you can read the original article Efron, B., & Tibshirani, R. (1993). An introduction to the bootstrap. Chapman & Hall. page 222 $\endgroup$
    – panda
    Commented Sep 3, 2021 at 11:25

Regarding testing the null hypothesis (H0) "the mean of X is not greater than the mean of Y" vs. the alternative "the mean of X is greater than the mean of Y":

In fact, the algorithm on the Wikipedia page is written down so that it rejects the H0 if the sample mean $\bar x$ is larger than $\bar y$ by enough distance, indicating a larger true mean of the $x$-data. If it is smaller, the H0 will not be rejected. This can be changed by changing the "$\ge$" to "$\le$" in step 6, or by taking absolute values of $t^*$ and $t$. However, in the current form I'd say it does what you want to do.

Formally, the null hypothesis of the test is that the two means are equal, because the distribution of the test statistic is simulated by bootstrap assuming that the means are equal. This is however not different from the standard (non-bootstrap) two-sample t-test. The reason why the H0 can there be stated as "mean of X is not greater as mean of Y" is that it can be proved that if in fact the mean of Y is larger, the rejection probability of the H0 is even smaller than if the means are equal, so that the test, even though computed assuming equality, is "unbiased" if the mean of Y is even larger.

This cannot be proved for the bootstrap test, or at least not as long as you are not willing to make further assumptions, because the nonparametric class of possible models is just too rich and all kinds of weird stuff can happen (I presume but am not sure that a mean shift model will do). Nevertheless, the bootstrap test is constructed so that it should tend to reject if the X-mean is larger, and should not tend to reject if the Y-mean is larger, so I think it allows the kind of interpretation that you have in mind.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.