time-to-botec

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

percentile-of-score-test.js (1426B)


      1 var vows = require('vows');
      2 var assert = require('assert');
      3 var suite = vows.describe('jStat.percentileOfScore');
      4 
      5 require('../env.js');
      6 
      7 var tol = 0.0000001;
      8 
      9 suite.addBatch({
     10   'percentiles': {
     11     'topic': function() {
     12       return jStat;
     13     },
     14     'return basic percentile of score': function(jStat) {
     15       assert.deepEqual(jStat.percentileOfScore([1, 2, 3, 4, 5, 6], 3), 0.5);
     16       assert.epsilon(tol,
     17                      jStat.percentileOfScore([1, 2, 3, 4, 5, 6], 5),
     18                      0.83333333333333343);
     19     },
     20     'return basic percentile of score: left extreme': function(jStat) {
     21       assert.deepEqual(jStat.percentileOfScore([1, 2, 3, 4, 5, 6], -1), 0.0);
     22     },
     23     'return basic percentile of score: right extreme': function(jStat) {
     24       assert.deepEqual(jStat.percentileOfScore([1, 2, 3, 4, 5, 6], 6), 1.0);
     25     },
     26     'return basic percentile of score (strict)': function(jStat) {
     27       assert.epsilon(
     28           tol,
     29           jStat.percentileOfScore([1, 2, 3, 4, 5, 6], 5, 'strict'),
     30           0.66666666666666657);
     31     },
     32     'percentile of score from instance': function(jStat) {
     33       assert.deepEqual(jStat([1, 2, 3, 4, 5, 6]).percentileOfScore(3), 0.5);
     34     },
     35     'percentile of score matrix cols': function(jStat) {
     36       var mat = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]];
     37       assert.deepEqual(jStat(mat).percentileOfScore(3), [0.5, 0.5]);
     38     }
     39   }
     40 });
     41 
     42 suite.export(module);