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 = 0, Alt alt = Alt.twoSided, double confLevel = 0.95)
    studentsTTest
    (
    T
    )
    (
    ,
    double testMean = 0
    ,,
    double confLevel = 0.95
    )
  2. ConfInt studentsTTest(T sample1, U sample2, double testMean = 0, Alt alt = Alt.twoSided, double confLevel = 0.95)

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

1 uint[] data = [1,2,3,4,5];
2 
3 // Test the null hypothesis that the mean of data is >= 1 against the
4 // alternative that the mean of data is < 1.  Calculate confidence
5 // intervals at 90%.
6 auto result1 = studentsTTest(data, 1, Alt.less, 0.9);
7 
8 // Do the same thing, only this time we've already calculated the summary
9 // statistics explicitly before passing them to studensTTest.
10 auto summary = meanStdev(data);
11 writeln(summary.stdev);
12 result2 = studentsTTest(summary, 1, Alt.less, 0.9);  // Same as result1.
13 assert(result1 == result2);

Meta