When one sample is fixed (as in the first set of code), the Null hypothesis is not true. This happens because, in the first set of code, s0 will have some mean that does not exactly equal 0. Because the normal distribution is continuous, the probability of drawing 1000 i.i.d. normals with a mean of exactly 0 is 0. Therefore, the loops in the first set of code all involve t-tests where the Null hypothesis is false because they involve comparing $\mu_1$ to $\mu_2$ where $\mu_1\neq0$ and $\mu_2=0$.
Anthony
- 1.7k
- 15
- 26