time-to-botec/squiggle/node_modules/jstat/test/vector/coeffvar-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
1.0 KiB
JavaScript

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