deno.land / x / simplestatistic@v7.7.1 / test / r_squared.test.js
123456789101112131415161718192021222324252627282930313233343536373839404142/* eslint no-shadow: 0 */
const test = require("tap").test;const ss = require("../");
test("r-squared", function (t) { t.test( "says that the r squared of a two-point line is perfect", function (t) { const d = [ [0, 0], [1, 1] ]; const l = ss.linearRegressionLine(ss.linearRegression(d)); t.equal(ss.rSquared(d, l), 1); t.end(); } );
t.test( "says that the r squared of a three-point line is not perfect", function (t) { const d = [ [0, 0], [0.5, 0.2], [1, 1] ]; const l = ss.linearRegressionLine(ss.linearRegression(d)); t.not(ss.rSquared(d, l), 1); t.end(); } );
t.test("r-squared of single sample is 1", function (t) { const d = [[0, 0]]; const l = ss.linearRegressionLine(ss.linearRegression(d)); t.equal(ss.rSquared(d, l), 1); t.end(); }); t.end();});
Version Info