https://github.com/probmods/webppl
Raw File
Tip revision: 57ceb940ce6e297c638a62a93a864cc3955b83d2 authored by Andreas Stuhlmueller on 06 August 2018, 21:06:15 UTC
0.9.13
Tip revision: 57ceb94
test-statistics.js
'use strict';

var stats = require('../src/math/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