permutationTest
permutationTest(
sampleX,sampleY,alternative?,k,randomSource?):number
Defined in: src/permutation_test.js:26
Conducts a permutation test to determine if two data sets are significantly different from each other, using the difference of means between the groups as the test statistic. The function allows for the following hypotheses:
- two_side = Null hypothesis: the two distributions are equal.
- greater = Null hypothesis: observations from sampleX tend to be smaller than those from sampleY.
- less = Null hypothesis: observations from sampleX tend to be greater than those from sampleY. Learn more about one-tail vs two-tail tests.
Parameters
Section titled “Parameters”sampleX
Section titled “sampleX”number[]
first dataset (e.g. treatment data)
sampleY
Section titled “sampleY”number[]
second dataset (e.g. control data)
alternative?
Section titled “alternative?”"two_side" | "greater" | "less"
alternative hypothesis
number
number of values in permutation distribution.
randomSource?
Section titled “randomSource?”Function
an optional entropy source
Returns
Section titled “Returns”number
p-value The probability of observing the difference between groups (as or more extreme than what we did), assuming the null hypothesis.
Example
Section titled “Example”var control = [2, 5, 3, 6, 7, 2, 5];var treatment = [20, 5, 13, 12, 7, 2, 2];permutationTest(control, treatment); // ~0.1324