Documentation |
T-test for a mean
This functionality does not run in MATLAB.
stats::tTest(x_{1}, x_{2}, …, m, <Normal>) stats::tTest([x_{1}, x_{2}, …], m, <Normal>) stats::tTest(s, <c>, m, <Normal>)
stats::tTest( [x_{1}, x_{2}, …], m ) tests the null hypothesis: "the true mean of the data x_{i} is larger than m".
stats::tTest accepts numerical data as well as symbolic data.
If all data are real floating-point numbers, the returned values p and t are floating-point numbers.
If m is a floating-point number, the sample data are converted to floating-point numbers automatically.
For a sample x_{1}, x_{2}, … of size n, stats::tTest computes , where
is the empirical mean of the data and
is the empirical variance.
stats::tTest(data, m) returns the list [PValue = p, StatValue = t], where the observed significance level p is computed as p = stats::tCDF(n - 1)(t).
stats::tTest(data, m, Normal) returns the list [PValue = p, StatValue = t], where the observed significance level p is computed as p = stats::normalCDF(0, 1)(t). For large n, this is an approximation of stats::tCDF(n - 1)(t).
Intuitively, p corresponds to the "probability" that the true mean of the data (the expectation value of the underlying distribution) is larger than m.
The most relevant information returned by stats::tTest is the observed significance level PValue = p. It has to be interpreted in the following way:
The t-test may be used as a one-tailed test of the null hypothesis: "the true mean of the data is larger than m". In this case, the null hypothesis may be rejected at level α if the observed significance level p satisfies p < α.
Alternatively, the t-test may also be used as a one-tailed test of the null hypothesis: "the true mean of the data is smaller than m". In this case, the null hypothesis may be rejected at level α if the observed "significance level" p satisfies p > 1 - α.
Alternatively, the t-test may also be used as a two-tailed test of the null hypothesis: "the true mean of the data is m". If the observed "significance level" p returned by stats::tTest satisfies either or for some given level 0 < α < 1, this null hypothesis may be rejected at level α.
External statistical data stored in an ASCII file can be imported into a MuPAD^{®} session via import::readdata. In particular, see Example 1 of the corresponding help page.
The function is sensitive to the environment variable DIGITS which determines the numerical working precision.
10 experiments produced the values 1, - 2, 3, - 4, 5, - 6, 7, - 8, 9, 10, which are assumed to be normally distributed with unknown mean and variance. The empirical mean of the sample data is 1.5. There is only a small probability p = that the true mean is larger than 5.0:
data := [1, -2, 3, -4, 5, -6, 7, -8, 9, 10]: stats::tTest(data, 5.0)
We compare this result with the observed significance level computed via a standard normal distribution:
stats::tTest(data, 5.0, Normal)
The approximation of the observed significance level p by the standard normal distribution is rather poor because of the small sample size. Next, we consider a larger sample. The true mean of the random data should be 10:
r := stats::normalRandom(10, 12, Seed = 0): data := [r() $ i = 1..100]: stats::tTest(data, 10);
stats::tTest(data, 10, Normal)
With the observed significance level of p = , the data are not disqualified as having the true mean 10. For samples of this size, the normal distribution approximates the t-distribution well.
delete data, r:
x_{1}, x_{2}, … |
The statistical data: arithmetical expressions |
m |
The estimate for the true mean of the data: an arithmetical expression |
s |
A sample of domain type stats::sample. |
c |
An integer representing a column index of the sample s. This column provides the data x_{1}, x_{2} etc. There is no need to specify a column number c if the sample has only one non-string column. |
Normal |
Compute the observed significance level by a standard normal distribution instead of a t-distribution. |
a list of two equations [PValue = p, StatValue = t] with numerical values p and t. See the `Details' section below for the interpretation of these values.
If the variance of the data vanishes, FAIL is returned.
If the data are normally distributed with expectation value ('true mean') μ, the variable is t-distributed with n - 1 degrees of freedom. The probability of the event that T attains values not larger than t is Pr(T ≤ t)=stats::tCDF(n - 1)(t).