time-to-botec

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

student-t-test.js (1276B)


      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   'studentt pdf': {
      9     'topic': function() {
     10       return jStat;
     11     },
     12     //Checked against R dt(x,df)
     13     'check pdf calculation': function(jStat) {
     14       var tol = 0.0000001;
     15       assert.epsilon(tol, jStat.studentt.pdf(0.5, 40), 0.3489195);
     16       assert.epsilon(tol, jStat.studentt.pdf(-1.0, 20), 0.2360456);
     17     },
     18     'check pdf calculation for large parameters': function(jStat) {
     19       var tol = 0.0000001;
     20       assert.epsilon(tol, jStat.studentt.pdf(0.45, 400), 0.3602198);
     21       assert.epsilon(tol, jStat.studentt.pdf(2.95, 525), 0.005283244);
     22     },
     23     //Checked against R's pt(x, df)
     24     'check cdf calculation': function(jStat) {
     25       var tol = 0.0000001;
     26       var x = 0.5;
     27       var df = 40;
     28       assert.epsilon(tol, jStat.studentt.cdf(x, df), 0.6900926);
     29     },
     30     //Checked against R's qt(x, df)
     31     'check inv calculation': function(jStat) {
     32       var tol = 0.0000001;
     33       assert.epsilon(tol, jStat.studentt.inv(0.5, 40), 0);
     34       assert.epsilon(tol, jStat.studentt.inv(0.7, 20), 0.5328628);
     35       assert.epsilon(tol, jStat.studentt.inv(0.2, 10), -0.8790578);
     36     }
     37   },
     38 });
     39 
     40 suite.export(module);