@nexys/math-ts
Version:
[](https://www.npmjs.com/package/@nexys/math-ts) [](https://travis-ci.com/github/Nexysweb/math-ts) [ • 675 B
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const V = __importStar(require("../vector"));
exports.estimate = (d) => {
const n = d.length;
const mean = V.mean(d);
const war = 1 / (n - 1) * V.s(d.map(e => Math.pow((e - mean), 2)));
const std = Math.sqrt(war);
return { n, mean, war, std };
};
exports.stddev = (d) => exports.estimate(d).std;