https://github.com/probmods/webppl
Raw File
Tip revision: ea53ee6f9b4dae952fe2023404981a6bb90c20db authored by Andreas Stuhlmüller on 08 February 2016, 01:02:44 UTC
0.6.1
Tip revision: ea53ee6
test-statistics.js
'use strict';

var stats = require('../src/statistics');

module.exports = {

  testMean: {

    test1: function(test) {
      test.strictEqual(stats.mean([0, 3, 9]), 4);
      test.done();
    },
    test2: function(test) {
      test.strictEqual(stats.mean(new Float64Array([0, 3, 9])), 4);
      test.done();
    },
    test3: function(test) {
      test.throws(function() { stats.mean([]); });
      test.done();
    }

  },

  testStandardDeviation: {

    test1: function(test) {
      test.strictEqual(stats.sd([0, 1, 2]), Math.sqrt(2 / 3));
      test.done();
    },
    test2: function(test) {
      test.strictEqual(stats.sd(new Float64Array([0, 1, 2])), Math.sqrt(2 / 3));
      test.done();
    },
    test3: function(test) {
      test.throws(function() { stats.sd([]); });
      test.done();
    }

  }

};
back to top