This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# TTest

 TTest[data] tests whether the mean of data is zero. TTesttests whether the means of and are equal. TTesttests the mean against . TTestreturns the value of .
• TTest performs a hypothesis test on data with null hypothesis that the true population mean is some value , and alternative hypothesis that .
• Given and , TTest tests that against that .
• By default a probability value or -value is returned.
• A small -value suggests that it is unlikely that is true.
• The data in dspec can be univariate or multivariate .
• The argument can be a real number or a real vector with length equal to the dimension of the data.
• TTest assumes that the data is normally distributed but is fairly robust to this assumption. TTest also assumes that the samples are independent in the two sample case.
• TTest returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
• TTest can be used to directly give the value of .
• Properties related to the reporting of test results include:
 "DegreesOfFreedom" the degrees of freedom used in a test "PValue" list of -values "PValueTable" formatted table of -values "ShortTestConclusion" a short description of the conclusion of a test "TestConclusion" a description of the conclusion of a test "TestData" list of pairs of test statistics and -values "TestDataTable" formatted table of -values and test statistics "TestStatistic" list of test statistics "TestStatisticTable" formatted table of test statistics
• The degrees of freedom df, used to specify the distribution of the test statistic, depend on the sample size, number of samples, and in the case of two univariate samples, the results of a test for equal variances.
• The following options can be used:
 AlternativeHypothesis "Unequal" the inequality for the alternative hypothesis SignificanceLevel 0.05 cutoff for diagnostics and reporting VerifyTestAssumptions Automatic what assumptions to verify
• For the TTest, a cutoff is chosen such that is rejected only if . The value of used for the and properties is controlled by the SignificanceLevel option. This value is also used in diagnostic tests of assumptions, including tests for normality, equal variance, and symmetry. By default is set to .
 "Normality" verify that all data is normally distributed "EqualVariance" verify that and have equal variance
Test whether the mean of a population is zero:
The full test table:
Test whether the means of two populations differ by 2:
The mean difference :
At the 0.05 level, is significantly different from 2:
Compare the locations of multivariate populations:
The mean difference vector :
At the 0.05 level, is not significantly different from :
Test whether the mean of a population is zero:
 Out[2]=
The full test table:
 Out[3]=

Test whether the means of two populations differ by 2:
The mean difference :
 Out[2]=
 Out[3]=
At the 0.05 level, is significantly different from 2:
 Out[4]=

Compare the locations of multivariate populations:
The mean difference vector :
 Out[2]=
 Out[3]=
At the 0.05 level, is not significantly different from :
 Out[4]=
 Scope   (13)
Test versus :
The -values are typically large when the mean is close to :
The -values are typically small when the location is far from :
Using Automatic is equivalent to testing for a mean of zero:
Test versus :
The -values are typically large when the mean is close to :
The -values are typically small when the location is far from :
Test whether the mean vector of a multivariate dataset is the zero vector:
Alternatively, test against :
Test versus :
The -values are generally small when the locations are not equal:
The -values are generally large when the locations are equal:
Test versus :
The order of the datasets affects the test results:
Test whether the mean difference vector of two multivariate datasets is the zero vector:
Alternatively, test against :
Create a HypothesisTestData object for repeated property extraction:
The properties available for extraction:
Extract some properties from a HypothesisTestData object:
The -value, test statistic, and degrees of freedom:
Extract any number of properties simultaneously:
The -value, test statistic, and degrees of freedom:
Tabulate the test results:
Retrieve the entries from a test table for customized reporting:
Tabulate -values or test statistics:
The -value from the table:
The test statistic from the table:
 Options   (11)
A two-sided test is performed by default:
Test versus :
Perform a two-sided test or a one-sided alternative:
Test versus :
Test versus :
Test versus :
Perform tests with one-sided alternatives when is given:
Test versus :
Test versus :
Set the significance level for diagnostic tests:
By default, is used:
The significance level is also used for and :
By default normality and equal variance are tested:
If assumptions are not checked, some test results may differ:
Diagnostics can be controlled as a group using All or None:
Verify all assumptions:
Check no assumptions:
Diagnostics can be controlled independently:
Assume normality but check for equal variances:
Only check for normality:
Unlisted assumptions are not tested:
Here, normality is assumed:
The result is the same but a warning is issued:
Bypassing diagnostic tests can save compute time:
It is often useful to bypass diagnostic tests for simulation purposes:
The assumptions of the test hold by design, so a great deal of time can be saved:
The results are identical:
 Applications   (4)
Test whether the means of some populations are equal:
The means of the first two populations are similar:
The mean of the third population is different from the first:
The "third series" of measurements of the passage time of light was recorded by Newcomb in 1882. The given values divided by 1000 plus 24 give the time in millionths of a second for light to traverse a known distance. The true value is now considered to be 33.02:
Use Chauvenet's criterion to identify outlying observations:
A -test on the bulk of the data suggests that Newcomb's measure of the speed of light was significantly lower than reality:
The vitamin C content and head weight were recorded for 30 samples from each of two experimental cabbage cultivars:
Plots of the head weight and vitamin C content by cultivar:
The vitamin C content is significantly higher for the c52 cultivar:
The weight data is not normally distributed for c52, so MannWhitneyTest is used to show that a significantly lighter cabbage produced significantly more vitamin C:
Fifty samples from each of three species of iris flowers were collected. The samples consist of measures of the length and width of the irises' sepals and petals. It is difficult to distinguish the species virginica and versicolor from one another:
A Hotelling test suggests a difference in the measures for the two similar species:
A visualization of the data suggests this difference is most prominent in the petal dimensions:
For univariate data, the test statistic follows StudentTDistribution under :
For multivariate data, the test statistic follows HotellingTSquareDistribution under :
The degrees of freedom are data dependent for univariate data:
One sample:
Two samples with equal variances:
Two samples with unequal variances (Satterthwaite approximation):
For multivariate data, the Mahalanobis distance is used to compute Hotelling's statistic:
Under , the test statistic follows HotellingTSquareDistribution:
If the population variance is known, the more powerful ZTest can be used:
ZTest correctly rejects more frequently than TTest:
If the data is not normally distributed, a median-based test should be used:
SignedRankTest is more powerful than SignTest but requires symmetric distributions:
TTest is robust to mild deviations from normality:
The -value can still be interpreted in the usual way:
Large deviations from normality require the use of median-based tests:
The -value can be interpreted in the usual way for SignedRankTest but not TTest:
For two-sample testing of non-normal data, use MannWhitneyTest:
For non-normal data, MannWhitneyTest can be more powerful than TTest:
TTest assumes that the data is normally distributed:
Use a median-based test that does not assume normality:
The covariance matrix of multivariate data may not be invertible:
New in 8