ttest

Perform the Student's t hypothesis test

#ttest

Perform the Student's t hypothesis test

npm install ttest
var ttest = require('ttest');
 
// One sample t-test 
ttest([0,1,1,1], {mu: 1}).valid() // true 
 
// Two sample t-test 
ttest([1,1,1,1], [2,2,2,2], {mu: -1}).valid() // true 
var ttest = require('ttest');

The ttest module supports both one and two sample t-testing, where it is assumed that the variance are equal.

If one array of data is given its a one sample t-test, and if two data arrays are given its a two sample t-test.

Note: instead of a data array a summary object can also be used.

In both cases you can also pass an extra optional object, there takes the following properties:

var options = {
  // Default: 0 
  // One sample case: this is the µ that the mean will be compared with 
  // Two sample case: this is the ∂ value that the mean diffrence will be compared with 
  mu: Number,
 
  // Default: 0.05 
  // The significance level of the test 
  alpha: Number,
 
  // Default "not equal" 
  // What should the alternative hypothesis be 
  // - One sample case: could the mean be less, greater or not equal to mu property 
  // - Two sample case: could the mean diffrence be less, greater or not equal to mu property 
  alternative: "less" || "greater" || "not equal"
};

The t-test object is finally created by calling the ttest constructor.

var res = ttest(sample, options);
var res = ttest(sampleA, sampleB, options);

When the ttest object is created you can get the following information.

Returns the t value also called the statistic value.

Returns the p-value.

Returns an array containing the confidence interval, where the confidence level is calculated as 1 - options.alpha. Where the lower limit has index 0 and the upper limit has index 1. If the alternative hypothesis is less or greater one of the sides will be +/- Infinity.

Simply returns true if the p-value is greater or equal to the alpha value.

Returns the degrees of freedom used in the t-test.

##License

The software is license under "MIT"

Copyright (c) 2013 Andreas Madsen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.