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

normal_distribution.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
73
/* eslint no-shadow: 0 */
const test = require("tap").test;const ss = require("../");
test("natural distribution and z-score", function (t) { t.test("normal table is exposed in the API", function (t) { t.equal(ss.standardNormalTable.length, 310); t.equal(ss.standardNormalTable[0], 0.5); t.end(); });
t.test("P(Z <= 0.4) is 0.6554", function (t) { // Taken from the examples of use in http://en.wikipedia.org/wiki/Standard_normal_table t.equal(ss.cumulativeStdNormalProbability(0.4), 0.6554); t.end(); });
t.test("P(Z <= -1.20) is 0.1151", function (t) { // Taken from the examples of use in http://en.wikipedia.org/wiki/Standard_normal_table t.equal(ss.cumulativeStdNormalProbability(-1.2), 0.1151); t.end(); });
t.test("P(X <= 82) when X ~ N (80, 25) is 0.6554", function (t) { // Taken from the examples of use in http://en.wikipedia.org/wiki/Standard_normal_table // A professor's exam scores are approximately distributed normally with mean 80 and standard deviation 5. // What is the probability that a student scores an 82 or less? t.equal( ss.cumulativeStdNormalProbability(ss.zScore(82, 80, 5)), 0.6554 ); t.end(); });
t.test("P(X >= 90) when X ~ N (80, 25) is 0.0228", function (t) { // Taken from the examples of use in http://en.wikipedia.org/wiki/Standard_normal_table // A professor's exam scores are approximately distributed normally with mean 80 and standard deviation 5. // What is the probability that a student scores a 90 or more? t.equal( +( 1 - ss.cumulativeStdNormalProbability(ss.zScore(90, 80, 5)) ).toPrecision(5), 0.0228 ); t.end(); });
t.test("P(X <= 74) when X ~ N (80, 25) is 0.1151", function (t) { // Taken from the examples of use in http://en.wikipedia.org/wiki/Standard_normal_table // A professor's exam scores are approximately distributed normally with mean 80 and standard deviation 5. // What is the probability that a student scores a 74 or less? t.equal( ss.cumulativeStdNormalProbability(ss.zScore(74, 80, 5)), 0.1151 ); t.end(); });
t.test("P(78 <= X <= 88) when X ~ N (80, 25) is 0.6006", function (t) { // Taken from the examples of use in http://en.wikipedia.org/wiki/Standard_normal_table // A professor's exam scores are approximately distributed normally with mean 80 and standard deviation 5. // What is the probability that a student scores between 78 and 88? const prob88 = ss.cumulativeStdNormalProbability(ss.zScore(88, 80, 5)); const prob78 = ss.cumulativeStdNormalProbability(ss.zScore(78, 80, 5));
t.equal(+(prob88 - prob78).toPrecision(5), 0.6006); t.end(); });
t.end();});
simplestatistic

Version Info

Tagged at
2 years ago