Skip to content

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.

number[]

first dataset (e.g. treatment data)

number[]

second dataset (e.g. control data)

"two_side" | "greater" | "less"

alternative hypothesis

number

number of values in permutation distribution.

Function

an optional entropy source

number

p-value The probability of observing the difference between groups (as or more extreme than what we did), assuming the null hypothesis.

var control = [2, 5, 3, 6, 7, 2, 5];
var treatment = [20, 5, 13, 12, 7, 2, 2];
permutationTest(control, treatment); // ~0.1324