The ttest function is correct. Remember to look at the p-value — the second output — to get the calculated probability. The first output is a flag indicating that the null hypothesis that the mean is equal to zero is accepted (0) or rejected (1).
The ttest function returns the probability (the second output) that the mean of the data is zero, so when you subtract the mean (as you did in ‘x1’), that probability is exactly 1 (within floating-point precision), because it is as certain as it is possible to express that the mean is not different from zero, and the null hypothesis is accepted.
Note that for ‘x2’, ‘h2’ is 1 and the p-value is vanishingly small, indicating that there is an infinitesimal probability (on the order of 1/10^79) that the mean of your data is equal to zero, and the null hypothesis is rejected.
‘But that doesn't necessarily mean that I have a T-distribution, right?’
Yes, it does. Your data have a t-distribution if they meet the criteria for it, regardless of the mean.
‘So if I subtract the mean of my values and p becomes 1, I have a T-distribution?’
Yes, if your data otherwise meet the criteria for having a t-distribution.
Best Answer