filer/perf/simple-statistics/test/sample_standard_deviation.t...

20 lines
509 B
JavaScript
Raw Permalink Normal View History

2014-12-17 07:54:29 +00:00
var test = require('tape');
var ss = require('../');
function rnd(x) {
return Math.round(x * 1000) / 1000;
}
test('sample_standard_deviation', function(t) {
test('can get the standard deviation of an example on wikipedia', function(t) {
t.equal(rnd(ss.sample_standard_deviation([2, 4, 4, 4, 5, 5, 7, 9])), 2.138);
t.end();
});
test('zero-length corner case', function(t) {
t.equal(rnd(ss.sample_standard_deviation([])), 0);
t.end();
});
t.end();
});