time-to-botec

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

uniform-test.js (876B)


      1 var vows = require('vows');
      2 var assert = require('assert');
      3 var suite = vows.describe('jStat.distribution');
      4 
      5 require('../env.js');
      6 
      7 suite.addBatch({
      8   'uniform pdf': {
      9     'topic': function() {
     10       return jStat;
     11     },
     12     'check pdf calculation': function(jStat) {
     13       var tol = 0.0000001;
     14       assert.epsilon(tol, jStat.uniform.pdf(10.5, 10, 11), 1.0);
     15       assert.epsilon(tol, jStat.uniform.pdf(6, 0, 10), 0.1);
     16     },
     17     'check cdf calculation': function(jStat) {
     18       var tol = 0.0000001;
     19       assert.epsilon(tol, jStat.uniform.cdf(7, 0, 10), 0.7);
     20       assert.epsilon(tol, jStat.uniform.cdf(10.5, 10, 11), 0.5);
     21     },
     22     'check inv calculation': function(jStat) {
     23       var tol = 0.0000001;
     24       assert.epsilon(tol, jStat.uniform.inv(0.5, 10, 11), 10.5);
     25       assert.epsilon(tol, jStat.uniform.inv(0.7, 0, 10), 7.0);
     26     }
     27   },
     28 });
     29 
     30 suite.export(module);