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

# ZTest

 ZTest[data] tests whether the mean of the data is zero. ZTesttests whether the means of and are equal. ZTesttests for zero or equal means assuming a population variance . ZTesttests the mean against. ZTestreturns the value of .
• ZTest performs a hypothesis test on data with null hypothesis that the true population mean is some value , and alternative hypothesis that .
• Given and , ZTest 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 .
• Given one dataset, the argument can be any positive real number or a positive definite matrix with dimension equal to the dimension of data.
• Given two datasets, the argument can be any positive real number, a positive definite matrix with dimension equal to the dimension of dspec, or two such numbers or matrices.
• The argument can be a real number or a real vector with length equal to the dimension of the data.
• ZTest assumes that the data is normally distributed and that the variance is known and not estimated from the data.
• If variances or covariance matrices are not provided, ZTest treats the sample estimate as the known variance or covariance.
• ZTest returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
• ZTest can be used to directly give the value of .
• Properties related to the reporting of test results include:
 "DegreesOfFreedom" the degrees of freedom of a test "PValue" list of -values "PValueTable" formatted table of -values "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
• If a known variance is not provided, ZTest performs a -test assuming the sample variance is the known variance for univariate data and Hotelling's test assuming the sample covariance is the known covariance for multivariate data.
• Options include:
 AlternativeHypothesis "Unequal" the inequality for the alternative hypothesis SignificanceLevel 0.05 cutoff for diagnostics and reporting VerifyTestAssumptions All what assumptions to verify
• For tests of location, a cutoff is chosen such that is rejected if and 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
Test for zero mean, assuming a known variance of 1:
The mean of the dataset:
Compare the means of two populations, assuming known variances of 4 and 16:
The means are significantly different:
Compare the mean vectors of two multivariate populations:
Compare the mean vector of a multivariate population to :
The difference is significant:
Test for zero mean, assuming a known variance of 1:
 Out[2]=
 Out[3]=
The mean of the dataset:
 Out[4]=

Compare the means of two populations, assuming known variances of 4 and 16:
 Out[2]=
The means are significantly different:
 Out[3]=

Compare the mean vectors of two multivariate populations:
 Out[2]=

Compare the mean vector of a multivariate population to :
 Out[2]=
The difference is significant:
 Out[3]=
 Scope   (17)
Set the known variance to :
Setting the known variance to Automatic is equivalent to using the sample variance:
The result is the same but a warning is issued:
Specify a single common variance for two groups or give a list of variances:
For multivariate data, covariance matrices can be given:
A single group covariance:
Separate covariance matrices for each dataset:
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 mean is close to :
The -values are typically small when the location is far from :
Test whether the mean vector of a multivariate population 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 populations 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 and test statistic:
Extract any number of properties simultaneously:
The -value and test statistic:
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   (9)
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 :
Control whether to verify the assumption of normality:
Assume normality:
Check for normality:
Alternatively:
Unlisted assumptions are not tested:
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   (1)
A factory creates 10-inch fuse casings on two separate lines. The length of these casings has known variance of 0.005 inches. In a quality control test, 25 casings were randomly selected from each of the two lines. A line is shut down and recalibrated if there is a significant deviation from 10 inches:
The first line performs as expected; the second needs to be recalibrated:
Suppose it is known that the factory machinery produces longer casings after prolonged use. The one-sided alternative is appropriate:
The univariate test statistic for one sample:
The test statistic follows a NormalDistribution under :
The multivariate test statistic for one sample:
Under , where p is the dimension of the data:
If variance is not specified, the test statistic is equivalent to that of TTest:
The -values are not equivalent:
In general ZTest is more powerful than TTest:
The test statistic does not follow a NormalDistribution if the sample variance is used:
TTest gives the appropriate -value when the sample variance is used:
The data should follow a NormalDistribution:
Use median-based tests if the data is not normally distributed:
LocationTest will pick an appropriate test automatically:
New in 8