studentsTTest - multiple declarations

Function 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.

ConfInt studentsTTest(T) (
  T data,
  double testMean = 0,
  Alt alt = Alt.twoSided,
  double confLevel = 0.95
)
if (isSummary!T || doubleIterable!T);

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

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);

Returns

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

Function studentsTTest

Two-sample T test for a difference in means, assumes variances of samples are equal. Alteratives are Alt.less, meaning mean(sample1) - mean(sample2) < testMean, Alt.greater, meaning mean(sample1) - mean(sample2) > testMean, and Alt.twoSided, meaning mean(sample1) - mean(sample2) != testMean.

ConfInt studentsTTest(T, U) (
  T sample1,
  U sample2,
  double testMean = 0,
  Alt alt = Alt.twoSided,
  double confLevel = 0.95
)
if ((doubleIterable!T || isSummary!T) && (doubleIterable!U || isSummary!U));

sample1 and sample2 may be either iterables with elements implicitly convertible to double or summary structs (see isSummary).

Returns

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

References

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