The 2-sample t-test determines if two population means and are the same. The procedure can handle 2-sample t-tests for equal variances and Welch's t-tests for unequal variances.
The null hypothesis and alternative hypothesis can be written as: : , and :
The procedure defaults to Welch's t-test for unequal variances if eq_var
is not specified.
In this case, the test statstic is calculated as follows:
where and are the sample means
and are the sample standard deviations, and
and are the sample sizes.
The degrees of freedom is approximated with the Welch–Satterthwaite equation:
If variances are assumed to be equal (eq_var = .true.
),
the procedure conducts a 2 sample t-test for equal variances, using the pooled standard
deviation to calculate the t-statistic:
In case of assumed equal variances, the degrees of freedom is calculated as follows:
Impure wrapper procedure for s_tst_ttest_2s_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1(:) |
x1 vector (samples) |
||
real(kind=wp), | intent(in) | :: | x2(:) |
x2 vector (samples) |
||
real(kind=wp), | intent(out) | :: | t |
test statistic |
||
real(kind=wp), | intent(out) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(out) | :: | p |
p-value |
||
logical, | intent(in), | optional | :: | eq_var |
true if equal variances assumed |
|
character(len=*), | intent(in), | optional | :: | h1 |
option: two (default), le, ge |