deno.land / x / simplestatistics@v7.8.3 / test / permutation_test.test.js
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172/* eslint no-shadow: 0 */
const test = require("tap").test;const Random = require("random-js");const random = new Random.Random(Random.MersenneTwister19937.seed(0));const ss = require("../dist/simple-statistics.js");
function rng() { return random.real(0, 1);}
test("permutation test", function (t) { t.test( "P-value of identical distributions being different should be 1", function (t) { t.equal( ss.permutationTest([2, 2, 2, 2, 2], [2, 2, 2, 2, 2]), 1, undefined, rng ); t.end(); } ); t.test( "P-value of distribution less than itself should be 1", function (t) { t.equal( ss.permutationTest( [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], "greater", undefined, rng ), 1 ); t.end(); } ); t.test( "P-value of small sample greater than large sample should be 0", function (t) { t.ok( ss.permutationTest( [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [ 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999 ], "less", undefined, rng ) < ss.epsilon ); t.end(); } );
t.test( "permutationTest should throw error if wrong argument received", function (t) { t.throws(function () { ss.permutationTest([1, 69, 420], [42, 42, 42], "one-tailed"); }, "alternative must be one of specified options"); t.end(); } );
t.end();});
Version Info