two-data-set.js 632 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Distribution = require('distributions').Studentt;
  3. const AbstactStudentT = require('./abstact.js');
  4. class StudentT extends AbstactStudentT {
  5. constructor(left, right, options) {
  6. super(options);
  7. this._df = left.size + right.size - 2;
  8. this._dist = new Distribution(this._df);
  9. const commonVariance = ((left.size - 1) * left.variance +
  10. (right.size - 1) * right.variance
  11. ) / this._df;
  12. this._se = Math.sqrt(commonVariance * (1 / left.size + 1 / right.size));
  13. this._mean = left.mean - right.mean;
  14. }
  15. }
  16. module.exports = StudentT;