UNPKG

983 BJavaScriptView Raw
1import { factory } from '../../utils/factory.js';
2import { createStd } from '../../function/statistics/std.js';
3import { errorTransform } from './utils/errorTransform.js';
4import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
5var name = 'std';
6var dependencies = ['typed', 'sqrt', 'variance'];
7/**
8 * Attach a transform function to math.std
9 * Adds a property transform containing the transform function.
10 *
11 * This transform changed the `dim` parameter of function std
12 * from one-based to zero based
13 */
14
15export var createStdTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
16 var {
17 typed,
18 sqrt,
19 variance
20 } = _ref;
21 var std = createStd({
22 typed,
23 sqrt,
24 variance
25 });
26 return typed('std', {
27 '...any': function any(args) {
28 args = lastDimToZeroBase(args);
29
30 try {
31 return std.apply(null, args);
32 } catch (err) {
33 throw errorTransform(err);
34 }
35 }
36 });
37}, {
38 isTransformFunction: true
39});
\No newline at end of file