time-to-botec

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

lognormal-test.js (1182B)


      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   'lognormal pdf': {
      9     'topic': function() {
     10       return jStat;
     11     },
     12     // Checked against R's dlnorm(x, meanlog = 0, sdlog = 1, log = FALSE)
     13     //   options(digits=10)
     14     //   dlnorm(c(-2, 0, 4), 4, 5)
     15     'check pdf calculation': function(jStat) {
     16       var tol = 0.0000001;
     17       assert.epsilon(tol, jStat.lognormal.pdf(-2, 4, 5), 0);
     18       assert.epsilon(tol, jStat.lognormal.pdf(0, 4, 5), 0);
     19       assert.epsilon(tol, jStat.lognormal.pdf(4, 4, 5), 0.01739974114);
     20     }
     21   },
     22   'lognormal cdf': {
     23     'topic': function() {
     24       return jStat;
     25     },
     26     // Checked against R's
     27     // plnorm(q, meanlog = 0, sdlog = 1, lower.tail = TRUE, log.p = FALSE)
     28     //   options(digits=10)
     29     //   plnorm(c(-2, 0, 4), 4, 5)
     30     'check cdf calculation': function(jStat) {
     31       var tol = 0.0000001;
     32       assert.epsilon(tol, jStat.lognormal.cdf(-2, 4, 5), 0);
     33       assert.epsilon(tol, jStat.lognormal.cdf(0, 4, 5), 0);
     34       assert.epsilon(tol, jStat.lognormal.cdf(4, 4, 5), 0.3005772067);
     35     }
     36   },
     37 });
     38 
     39 suite.export(module);