time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

spearman-test.js (942B)


      1 var vows = require('vows');
      2 var assert = require('assert');
      3 var suite = vows.describe('jStat.spearmancoeff');
      4 
      5 require('../env.js');
      6 
      7 var tol = 0.0000001;
      8 
      9 suite.addBatch({
     10   'spearman': {
     11     'topic': function() {
     12       return jStat;
     13     },
     14     'return basic spearmancoeff': function(jStat) {
     15       assert.epsilon(tol, jStat.spearmancoeff([1, 2, 3, 4], [5, 6, 9, 7]), 0.8);
     16     },
     17     'return spearmancoeff with ties': function(jStat) {
     18       assert.epsilon(tol,
     19                      jStat.spearmancoeff([1, 2, 3, 4], [5, 5, 9, 7]),
     20                      0.7378647873726218);
     21     },
     22     'return spearmancoeff all ties': function(jStat) {
     23       assert.equal(isNaN(jStat.spearmancoeff([1, 2, 3, 4], [5, 5, 5, 5])),
     24                    true);
     25     },
     26     'return spearmancoeff unequal arrays': function(jStat) {
     27       assert.equal(isNaN(jStat.spearmancoeff([1, 2, 3, 4], [5, 6, 7])),
     28                    true);
     29     }
     30   }
     31 });
     32 
     33 suite.export(module);