coeffvar-test.js (1057B)
1 var vows = require('vows'); 2 var assert = require('assert'); 3 var suite = vows.describe('jStat.coeffvar'); 4 5 require('../env.js'); 6 7 suite.addBatch({ 8 'coeffvar': { 9 'topic': function() { 10 return jStat; 11 }, 12 'return basic coeffvar': function(jStat) { 13 assert.equal(jStat.coeffvar([1, 2, 3, 4]), 0.447213595499958); 14 }, 15 'coeffvar from instance': function(jStat) { 16 assert.equal(jStat([1, 2, 3, 4]).coeffvar(), 0.447213595499958); 17 }, 18 'coeffvar matrix cols': function(jStat) { 19 assert.deepEqual(jStat([[1, 2], [4, 6]]).coeffvar(), [0.6, 0.5]); 20 } 21 }, 22 '#coeffvar vector': { 23 'topic': function() { 24 jStat([1, 2, 3, 4]).coeffvar(this.callback); 25 }, 26 'coeffvar callback': function(val, stat) { 27 assert.equal(val, 0.447213595499958); 28 } 29 }, 30 '#coeffvar matrix cols': { 31 'topic': function() { 32 jStat([[1, 2], [4, 6]]).coeffvar(this.callback); 33 }, 34 'coeffvar matrix cols callback': function(val, stat) { 35 assert.deepEqual(val, [0.6, 0.5]); 36 } 37 } 38 }); 39 40 suite.export(module);