The OpenD Programming Language

studentsTTest

One-sample Student's T-test for difference between mean of data and a fixed value. Alternatives are Alt.less, meaning mean(data) < testMean, Alt.greater, meaning mean(data) > testMean, and Alt.twoSided, meaning mean(data)!= testMean.

data may be either an iterable with elements implicitly convertible to double or a summary struct (see isSummary).

  1. ConfInt studentsTTest(T data, double testMean, Alt alt, double confLevel)
    studentsTTest
    (
    T
    )
    (,
    double testMean = 0
    ,,
    double confLevel = 0.95
    )
  2. ConfInt studentsTTest(T sample1, U sample2, double testMean, Alt alt, double confLevel)

Return Value

Type: ConfInt

A ConfInt containing T, the P-value and the boundaries of the confidence interval for mean(data) at the level specified.

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

Examples

uint[] data = [1,2,3,4,5];

// Test the null hypothesis that the mean of data is >= 1 against the
// alternative that the mean of data is < 1.  Calculate confidence
// intervals at 90%.
auto result1 = studentsTTest(data, 1, Alt.less, 0.9);

// Do the same thing, only this time we've already calculated the summary
// statistics explicitly before passing them to studensTTest.
auto summary = meanStdev(data);
writeln(summary.stdev);
result2 = studentsTTest(summary, 1, Alt.less, 0.9);  // Same as result1.
assert(result1 == result2);

Meta