pairedTTest - multiple declarations

Function pairedTTest

Paired T test. Tests the hypothesis that the mean difference between corresponding elements of before and after is testMean. Alternatives are Alt.less, meaning the that the true mean difference (before[i] - after[i]) is less than testMean, Alt.greater, meaning the true mean difference is greater than testMean, and Alt.twoSided, meaning the true mean difference is not equal to testMean.

ConfInt pairedTTest(T, U) (
  T before,
  U after,
  double testMean = 0,
  Alt alt = Alt.twoSided,
  double confLevel = 0.95
)
if (doubleInput!T && doubleInput!U && isInputRange!T && isInputRange!U);

before and after must be input ranges with elements implicitly convertible to double and must have the same length.

Returns

A ConfInt containing the T statistic, the P-value, and the boundaries of the confidence interval for the mean difference between corresponding elements of sample1 and sample2 at the specified level.

References

http://en.wikipedia.org/wiki/Student%27s_t-test

Function pairedTTest

Compute a paired T test directly from summary statistics of the differences between corresponding samples.

ConfInt pairedTTest(T) (
  T diffSummary,
  double testMean = 0,
  Alt alt = Alt.twoSided,
  double confLevel = 0.95
)
if (isSummary!T);

Examples

float[] data1 = [8, 6, 7, 5, 3, 0, 9];
float[] data2 = [3, 6, 2, 4, 3, 6, 8];

// Calculate summary statistics on difference explicitly.
MeanSD summary;
foreach(i; 0..data1.length) {
    summary.put(data1[i] - data2[i]);
}

// Test the null hypothesis that the mean difference between corresponding
// elements (data1[i] - data2[i]) is greater than 5 against the null that it
// is <= 5.  Calculate confidence intervals at 99%.
auto result = pairedTTest(summary, 5, Alt.twoSided, 0.99);

// This is equivalent to:
auto result2 = pairedTTest(data1, data2, 5, Alt.twoSided, 0.99);

References

http://en.wikipedia.org/wiki/Student%27s_t-test