naginterfaces.library.univar.ttest_2normal¶
- naginterfaces.library.univar.ttest_2normal(tail, equal, nx, ny, xmean, ymean, xstd, ystd, clevel)[source]¶
ttest_2normal
computes a -test statistic to test for a difference in means between two Normal populations, together with a confidence interval for the difference between the means.For full information please refer to the NAG Library document for g07ca
https://www.nag.com/numeric/nl/nagdoc_28.7/flhtml/g07/g07caf.html
- Parameters
- tailstr, length 1
Indicates which tail probability is to be calculated, and thus which alternative hypothesis is to be used.
The two tail probability, i.e., .
The upper tail probability, i.e., .
The lower tail probability, i.e., .
- equalstr, length 1
Indicates whether the population variances are assumed to be equal or not.
The population variances are assumed to be equal, that is .
The population variances are not assumed to be equal.
- nxint
, the size of the sample.
- nyint
, the size of the sample.
- xmeanfloat
, the mean of the sample.
- ymeanfloat
, the mean of the sample.
- xstdfloat
, the standard deviation of the sample.
- ystdfloat
, the standard deviation of the sample.
- clevelfloat
The confidence level, , for the specified tail. For example will give a confidence interval.
- Returns
- tfloat
Contains the test statistic, or .
- dffloat
Contains the degrees of freedom for the test statistic.
- probfloat
Contains the significance level, that is the tail probability, , as defined by .
- dlfloat
Contains the lower confidence limit for .
- dufloat
Contains the upper confidence limit for .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: , or .
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
Consider two independent samples, denoted by and , of size and drawn from two Normal populations with means and , and variances and respectively. Denote the sample means by and and the sample variances by and respectively.
ttest_2normal
calculates a test statistic and its significance level to test the null hypothesis , together with upper and lower confidence limits for . The test used depends on whether or not the two population variances are assumed to be equal.It is assumed that the two variances are equal, that is .
The test used is the two sample -test. The test statistic is defined by;
where
is the pooled variance of the two samples.
Under the null hypothesis this test statistic has a -distribution with degrees of freedom.
The test of is carried out against one of three possible alternatives;
; the significance level, , i.e., a two tailed probability.
; the significance level, , i.e., an upper tail probability.
; the significance level, , i.e., a lower tail probability.
Upper and lower confidence limits for are calculated as:
where is the percentage point of the -distribution with () degrees of freedom.
It is not assumed that the two variances are equal.
If the population variances are not equal the usual two sample -statistic no longer has a -distribution and an approximate test is used.
This problem is often referred to as the Behrens–Fisher problem, see Kendall and Stuart (1969). The test used here is based on Satterthwaites procedure. To test the null hypothesis the test statistic is used where
where .
A -distribution with degrees of freedom is used to approximate the distribution of where
The test of is carried out against one of the three alternative hypotheses described above, replacing by and by .
Upper and lower confidence limits for are calculated as:
where is the percentage point of the -distribution with degrees of freedom.
- References
Johnson, M G and Kotz, A, 1969, The Encyclopedia of Statistics (2), Griffin
Kendall, M G and Stuart, A, 1969, The Advanced Theory of Statistics (Volume 1), (3rd Edition), Griffin
Snedecor, G W and Cochran, W G, 1967, Statistical Methods, Iowa State University Press