time-to-botec/squiggle/node_modules/jstat/test/vector/meandev-test.js
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

41 lines
1006 B
JavaScript

var vows = require('vows');
var assert = require('assert');
var suite = vows.describe('jStat.meandev');
require('../env.js');
suite.addBatch({
'meandev': {
'topic': function() {
return jStat;
},
'return basic meandev': function(jStat) {
assert.equal(jStat.meandev([4, 5, 7, 22, 90, 1, 4, 5]), 19.375);
},
'meandev from instance': function(jStat) {
assert.equal(jStat([1, 2, 3, 4]).meandev(), 1);
},
'meandev matrix cols': function(jStat) {
assert.deepEqual(jStat([[1, 2], [3, 4]]).meandev(), [1, 1]);
}
},
'#meandev vector': {
'topic': function() {
jStat([1, 2, 3, 4]).meandev(this.callback);
},
'meandev callback': function(val, stat) {
assert.equal(val, 1);
}
},
'#meandev matrix cols': {
'topic': function() {
jStat([[1, 2], [3, 4]]).meandev(this.callback);
},
'meandev matrix cols callback': function(val, stat) {
assert.deepEqual(val, [1, 1]);
}
}
});
suite.export(module);