deno.land / x / simplestatistic@v7.7.1 / test / permutation_test.test.js

permutation_test.test.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* 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("../");
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();});
simplestatistic

Version Info

Tagged at
2 years ago