normal-test.js (923B)
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 'normal pdf': { 9 'topic': function() { 10 return jStat; 11 }, 12 13 //Checked against R's dnorm(x, mean, sd) 14 'check pdf calculation': function(jStat) { 15 var tol = 0.000001; 16 assert.epsilon(tol, jStat.normal.pdf(0, 0, 1.0), 0.3989423); 17 assert.epsilon(tol, jStat.normal.pdf(5, 10, 3.0), 0.03315905); 18 assert.epsilon(tol, jStat.normal.pdf(-1, 1, 0.5), 0.00026766); 19 }, 20 21 //Checked against R's qnorm(p, mean, sd) 22 'check inv calculation': function(jStat) { 23 var tol = 0.000001; 24 assert.epsilon(tol, jStat.normal.inv(0.3989423, 0, 1.0), -0.2560858); 25 assert.epsilon(tol, jStat.normal.inv(0.05, 10, 3.0), 5.065439); 26 assert.epsilon(tol, jStat.normal.inv(0.65, -2, .5), -1.80734); 27 } 28 } 29 }); 30 31 suite.export(module);