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

linear_regression.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
74
75
76
77
78
79
80
/* eslint no-shadow: 0 */
const test = require("tap").test;const linearRegression = require("../").linearRegression;const linearRegressionLine = require("../").linearRegressionLine;
test("linear regression", function (t) { t.test( "correctly generates a line for a 0, 0 to 1, 1 dataset", function (t) { const l = linearRegressionLine( linearRegression([ [0, 0], [1, 1] ]) ); t.equal(l(0), 0); t.equal(l(0.5), 0.5); t.equal(l(1), 1); t.end(); } );
t.test( "correctly generates a line for a 0, 0 to 1, 0 dataset", function (t) { const l = linearRegressionLine( linearRegression([ [0, 0], [1, 0] ]) ); t.equal(l(0), 0); t.equal(l(0.5), 0); t.equal(l(1), 0); t.end(); } );
t.test("handles a single-point sample", function (t) { const l = linearRegressionLine(linearRegression([[0, 0]])); t.same(l(10), 0); t.end(); });
t.test("a straight line will have a slope of 0", function (t) { t.same( linearRegression([ [0, 0], [1, 0] ]), { m: 0, b: 0 } ); t.end(); });
t.test("a line at 50% grade", function (t) { t.same( linearRegression([ [0, 0], [1, 0.5] ]), { m: 0.5, b: 0 } ); t.end(); });
t.test("a line with a high y-intercept", function (t) { t.same( linearRegression([ [0, 20], [1, 10] ]), { m: -10, b: 20 } ); t.end(); }); t.end();});
simplestatistic

Version Info

Tagged at
2 years ago