# Sample size needed to show difference of means is smaller than $y\%$

The unpaired $$t$$-test is commonly used to reject the null hypothesis that two sample means are equal.

However, suppose one wants to prove that the sample means are no different than some given maximal difference, i.e. we want to reject the hypothesis $$|\mu_1-\mu_2|>y\%$$. Moreover, suppose we have an a priori estimate of the pooled sample variance $$\sigma^2$$.

How can one calculate the minimal sample size needed $$n$$ so that we can reject this hypothesis with a given power?

• Null hypotheses typically do not have strict inequality, and are usually specified as based on "(almost) no difference" rather than "at least some specified absolute difference" which is strangely two-tailed. You might also say what $y\%$ means here: is that a percentage of $\mu_1$ or $\mu_2$? Commented Nov 3, 2022 at 9:13
• @Henry - The percentage shouldn't matter that much, it can be quantified as a specific number or a percentage of the mean of means, either the way the math should be the same. Commented Nov 3, 2022 at 14:24
• @Henry - Do see my answer below. Commented Nov 3, 2022 at 20:58
• Look for TOST : two one-sided t-tests Commented Nov 8, 2022 at 11:01

Using the CDF of the student-$$t$$ distribution: $$F(t)=1-\frac{1}{2}I_x(\nu/2,1/2),\quad x \equiv \frac{\nu}{\nu+t^2}$$ The $$p$$-value for the hypothesis $$H_0:|\mu_1-\mu_2|>y$$ assuming equal sample sizes and average standard deviation $$\sigma$$ is: $$t=\frac{\mu_1 - \mu_2}{\sigma\sqrt{2/N}}$$ $$P(H_0)=2-2F\left(\sqrt{\frac{N}{2}}\frac{y}{\sigma}\right)$$ If one is given a priori values of $$y$$ and $$\sigma$$ in terms of percentages of the expected value, one can then calculate $$N$$ for a given $$p$$-value. This answer is incomplete as it does not give $$N$$ explicitly nor does it give the dependence of $$N$$ on the power.