deno.land / x / simplestatistics@v7.8.3 / test / chi_squared_goodness_of_fit.test.js
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/* eslint no-shadow: 0 */
const test = require("tap").test;const ss = require("../dist/simple-statistics.js");
// Data from Poisson goodness-of-fit example 10-19 in William W. Hines & Douglas C. Montgomery,// "Probability and Statistics in Engineering and Management Science", Wiley (1980).const data1019 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3];
test("chiSquaredGoodnessOfFit", function (t) { t.test( "can reject the null hypothesis with level of confidence specified at 0.05", function (t) { t.equal( false, ss.chiSquaredGoodnessOfFit( data1019, ss.poissonDistribution, 0.05 ) ); t.end(); } ); t.test( "can accept the null hypothesis with level of confidence specified at 0.10", function (t) { t.equal( true, ss.chiSquaredGoodnessOfFit( data1019, ss.poissonDistribution, 0.1 ) ); t.end(); } ); t.test("can tolerate gaps in distribution", function (t) { t.equal( true, ss.chiSquaredGoodnessOfFit( [0, 2, 3, 7, 7, 7, 7, 7, 7, 9, 10], ss.poissonDistribution, 0.1 ) ); t.end(); }); t.end();});
Version Info