https://github.com/probmods/webppl
Tip revision: bed218dbe1cfdfd7b02670e05095a183da3542e5 authored by Andreas Stuhlmueller on 17 May 2017, 20:34:24 UTC
0.9.8
0.9.8
Tip revision: bed218d
test-statistics.js
'use strict';
var stats = require('../src/math/statistics');
module.exports = {
testMean: {
test1: function(test) {
test.strictEqual(stats.mean([0, 3, 9]), 4);
test.done();
},
test2: function(test) {
test.strictEqual(stats.mean(new Float64Array([0, 3, 9])), 4);
test.done();
},
test3: function(test) {
test.throws(function() { stats.mean([]); });
test.done();
}
},
testStandardDeviation: {
test1: function(test) {
test.strictEqual(stats.sd([0, 1, 2]), Math.sqrt(2 / 3));
test.done();
},
test2: function(test) {
test.strictEqual(stats.sd(new Float64Array([0, 1, 2])), Math.sqrt(2 / 3));
test.done();
},
test3: function(test) {
test.throws(function() { stats.sd([]); });
test.done();
}
}
};