TwoSampleTTest - Maple Help

Statistics

 TwoSampleTTest
 apply the two sample t-test for population means

 Calling Sequence TwoSampleTTest(X1, X2, beta, options)

Parameters

 X1 - first data sample X2 - second data sample beta - realcons; the test value for the difference between the two means options - (optional) equation(s) of the form option=value where option is one of alternative, confidence, equalvariances, ignore, output, summarize, weights1 or weights2; specify options for the TwoSampleTTest function

Description

 • The TwoSampleTTest function computes the two sample t-test on datasets X1 and X2.  This calculation is used to determine the significance of the difference between sample means and an assumed difference in population means when the standard deviation of the population is unknown.
 • The first parameter X1 is the first data sample to use in the analysis.
 • The second parameter X2 is the second data sample to use in the analysis.
 • The third parameter beta is the assumed difference in population means (assumed population mean of X1 minus the assumed population mean of X2), specified as a real constant.

Options

 The options argument can contain one or more of the options shown below.
 • alternative='twotailed', 'lowertail', or 'uppertail'
 This option is used to specify the type or interval used in the analysis, or similarly, the alternative hypothesis to consider when performing the analysis.
 • confidence=float
 This option is used to specify the confidence level of the interval and must be a floating-point value between 0 and 1.  By default this is set to 0.95.
 • equalvariances=truefalse
 This option is used to indicate if either the variance or the standard deviation of the two populations are known to be equal.  Specifying true all allows for a slightly better estimate as a result of the provided information.  By default, this option is false.
 • ignore=truefalse
 This option is used to specify how to handle non-numeric data. If ignore is set to true all non-numeric items in the data samples will be ignored.
 • output='report', 'statistic', 'pvalue', 'confidenceinterval', 'distribution', 'hypothesis', or list('statistic', 'pvalue', 'confidenceinterval', 'distribution', 'hypothesis')
 This option is used to specify the desired format of the output from the function.  If 'report' is specified then a module containing all output from this test is returned.  If a single parameter name is specified other than 'report' then that quantity alone is returned.  If a list of parameter names is specified then a list containing those quantities in the specified order will be returned.
 • summarize= 'true', 'false', 'embed'
 This option controls the display of a printed or embedded summary for the hypothesis test. Unlike the output option, the displayed summary is not assignable output.
 • weights1=rtable
 Vector of weights (one-dimensional rtable). If these weights are given, the TwoSampleTTest function will scale each data point in X1 to have given weight. Note that the weights provided must have type realcons and the results are floating-point, even if the problem is specified with exact values. Both the data array and the weights array must have the same number of elements.
 • weights2=rtable
 Vector of weights (one-dimensional rtable).  This parameter is equivalent to the option weights1, except applying to data in X2.

Notes

 • This test generates a complete report of all calculations in the form of a userinfo message.  In order to access this report, specify infolevel[Statistics] := 1 or use the summarize option.
 • A stronger version of the t-test, the z-test is available if the standard deviation of the sample is known.
 • If data samples are paired data (collected as a pair of observations rather than as independent observations), the paired t-test may be used.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$

Specify the data sample.

 > $X≔\mathrm{Array}\left(\left[9,10,8,4,8,3,0,10,15,9\right]\right):$
 > $Y≔\mathrm{Array}\left(\left[6,3,10,11,9,8,13,4,4,4\right]\right):$
 > $\mathrm{Mean}\left(X\right)-\mathrm{Mean}\left(Y\right)$
 ${0.399999999999999}$ (1)

Calculate the two sample t-test on an array of values.

 > $\mathrm{TwoSampleTTest}\left(X,Y,0,\mathrm{confidence}=0.95,\mathrm{summarize}=\mathrm{embed}\right):$

Null Hypothesis:

Sample drawn from populations with difference of means equal to 0

Alternative Hypothesis:

Sample drawn from population with difference of means not equal to 0

 Sample Size Sample Mean Sample Standard Deviation Difference in Means Sample 1 ${10.}$ ${7.60000}$ ${4.24788}$ ${0.400000}$ Sample 2 ${10.}$ ${7.20000}$ ${3.48967}$

 Distribution Computed Statistic Computed p-value Confidence Interval ${\mathrm{StudentT}}{}\left({17.3463603321217832}\right)$ ${0.230089}$ ${0.820714}$ ${-3.26225}{..}{4.06225}$

Result:

Accepted: This statistical test does not provide enough evidence to conclude that the null hypothesis is false.

Repeat the test with population variances indicated as equal.

 > $\mathrm{TwoSampleTTest}\left(X,Y,0,\mathrm{confidence}=0.95,\mathrm{equalvariances}=\mathrm{true},\mathrm{summarize}=\mathrm{true}\right)$
 Standard T-Test on Two Samples (Equal Variances)
 ------------------------------------------------
 Null Hypothesis: Sample drawn from populations with difference of means equal to 0
 Alt. Hypothesis: Sample drawn from population with difference of means not equal to 0
 Sample Sizes:            10, 10
 Sample Means:            7.6, 7.2
 Sample Standard Dev:     4.24788, 3.48967
 Difference in Means:     0.4
 Distribution:            StudentT(18)
 Computed Statistic:      .230089496654211
 Computed p-value:        .820616807777737
 Confidence Interval:     -3.252356255014 .. 4.05235625501399
 (difference of population means)
 Result: [Accepted] This statistical test does not provide enough evidence to conclude that the null hypothesis is false.
 ${\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{confidenceinterval}}{=}{-3.25235625501400}{..}{4.05235625501399}{,}{\mathrm{distribution}}{=}{\mathrm{StudentT}}{}\left({18}\right){,}{\mathrm{pvalue}}{=}{0.820616807777737}{,}{\mathrm{statistic}}{=}{0.230089496654211}$ (2)

As an alternative to using the summarize option, setting infolevel[Statistics] := 1 also returns the printed summary.

 > $\mathrm{infolevel}\left[\mathrm{Statistics}\right]≔1:$

Calculate the lower tail t-test.

 > $\mathrm{TwoSampleTTest}\left(X,Y,0,\mathrm{confidence}=0.95,\mathrm{alternative}='\mathrm{lowertail}'\right)$
 Standard T-Test on Two Samples (Unequal Variances)
 ------------------------------------------------
 Null Hypothesis: Sample drawn from populations with difference of means greater than 0
 Alt. Hypothesis: Sample drawn from population with difference of means less than 0
 Sample Sizes:            10, 10
 Sample Means:            7.6, 7.2
 Sample Standard Dev:     4.24788, 3.48967
 Difference in Means:     0.4
 Distribution:            StudentT(17.3463603321218)
 Computed Statistic:      .230089496654211
 Computed p-value:        .589643127747175
 Confidence Interval:     -infinity .. 3.42075593333579
 (difference of population means)
 Result: [Accepted] This statistical test does not provide enough evidence to conclude that the null hypothesis is false.
 ${\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{confidenceinterval}}{=}{-}{\mathrm{\infty }}{..}{3.42075593333579}{,}{\mathrm{distribution}}{=}{\mathrm{StudentT}}{}\left({17.3463603321218}\right){,}{\mathrm{pvalue}}{=}{0.589643127747175}{,}{\mathrm{statistic}}{=}{0.230089496654211}$ (3)

Calculate the upper tail t-test.

 > $\mathrm{TwoSampleTTest}\left(X,Y,0,\mathrm{confidence}=0.95,\mathrm{alternative}='\mathrm{uppertail}'\right)$
 Standard T-Test on Two Samples (Unequal Variances)
 ------------------------------------------------
 Null Hypothesis: Sample drawn from populations with difference of means less than 0
 Alt. Hypothesis: Sample drawn from population with difference of means greater than 0
 Sample Sizes:            10, 10
 Sample Means:            7.6, 7.2
 Sample Standard Dev:     4.24788, 3.48967
 Difference in Means:     0.4
 Distribution:            StudentT(17.3463603321218)
 Computed Statistic:      .230089496654211
 Computed p-value:        .410356872252825
 Confidence Interval:     -2.62075593333579 .. infinity
 (difference of population means)
 Result: [Accepted] This statistical test does not provide enough evidence to conclude that the null hypothesis is false.
 ${\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{confidenceinterval}}{=}{-2.62075593333579}{..}{\mathrm{\infty }}{,}{\mathrm{distribution}}{=}{\mathrm{StudentT}}{}\left({17.3463603321218}\right){,}{\mathrm{pvalue}}{=}{0.410356872252825}{,}{\mathrm{statistic}}{=}{0.230089496654211}$ (4)
 > 

References

 Kanji, Gopal K. 100 Statistical Tests. London: SAGE Publications Ltd., 1994.
 Sheskin, David J. Handbook of Parametric and Nonparametric Statistical Procedures. London: CRC Press, 1997.

Compatibility

 • The Statistics[TwoSampleTTest] command was updated in Maple 2016.
 • The summarize option was introduced in Maple 2016.