Perform the Student's t hypothesis test
Perform the Student t hypothesis test
npm install ttest
var ttest = ;// One sample t-test// true// Two sample t-test// true
var ttest = ;
ttest module supports both one and two sample t-testing, and both
equal and none equal variance.
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:
const 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: false// If true don't assume variance is equal and use the Welch approximation.// This only applies of two samples are used.varEqual: Boolean// Default: 0.05// The significance level of the testalpha: 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
const stat = ;const stat = ;
ttest object is created you can get the following information.
t value also called the
Returns an array containing the confidence interval, where the confidence level
is calculated as
1 - options.alpha. Where the lower limit has index
the upper limit has index
1. If the alternative hypothesis is
greater one of the sides will be
Simply returns true if the
p-value is greater or equal to the
Returns the degrees of freedom used in the t-test.