https://github.com/probmods/webppl
Raw File
Tip revision: 348fb3fe6c03fd0ea738e84596946da28e0cc3fc authored by null-a on 27 March 2018, 09:15:56 UTC
Remove unused require.
Tip revision: 348fb3f
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