time-to-botec/squiggle/node_modules/jstat/test/vector/spearman-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

34 lines
942 B
JavaScript

var vows = require('vows');
var assert = require('assert');
var suite = vows.describe('jStat.spearmancoeff');
require('../env.js');
var tol = 0.0000001;
suite.addBatch({
'spearman': {
'topic': function() {
return jStat;
},
'return basic spearmancoeff': function(jStat) {
assert.epsilon(tol, jStat.spearmancoeff([1, 2, 3, 4], [5, 6, 9, 7]), 0.8);
},
'return spearmancoeff with ties': function(jStat) {
assert.epsilon(tol,
jStat.spearmancoeff([1, 2, 3, 4], [5, 5, 9, 7]),
0.7378647873726218);
},
'return spearmancoeff all ties': function(jStat) {
assert.equal(isNaN(jStat.spearmancoeff([1, 2, 3, 4], [5, 5, 5, 5])),
true);
},
'return spearmancoeff unequal arrays': function(jStat) {
assert.equal(isNaN(jStat.spearmancoeff([1, 2, 3, 4], [5, 6, 7])),
true);
}
}
});
suite.export(module);