mathjs 10.3.0 → 10.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +14 -0
- package/docs/reference/functions/cumsum.md +57 -0
- package/docs/reference/functions/format.md +1 -1
- package/docs/reference/functions/sum.md +2 -1
- package/docs/reference/functions.md +1 -0
- package/lib/browser/math.js +4 -4
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesCumSum.generated.js +26 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +26 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +16 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesCumSum.generated.js +26 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +26 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +16 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +6 -0
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +6 -0
- package/lib/cjs/entry/pureFunctionsAny.generated.js +9 -3
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +8 -2
- package/lib/cjs/expression/embeddedDocs/construction/fraction.js +3 -3
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +3 -0
- package/lib/cjs/expression/embeddedDocs/function/statistics/cumsum.js +15 -0
- package/lib/cjs/expression/transform/cumsum.transform.js +57 -0
- package/lib/cjs/expression/transform/sum.transform.js +1 -1
- package/lib/cjs/factoriesAny.js +16 -0
- package/lib/cjs/factoriesNumber.js +17 -1
- package/lib/cjs/function/algebra/simplifyCore.js +2 -2
- package/lib/cjs/function/statistics/cumsum.js +151 -0
- package/lib/cjs/function/statistics/sum.js +1 -1
- package/lib/cjs/function/string/format.js +1 -1
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/fraction/function/fraction.js +20 -8
- package/lib/cjs/utils/collection.js +3 -27
- package/lib/cjs/utils/switch.js +31 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesCumSum.generated.js +14 -0
- package/lib/esm/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +14 -0
- package/lib/esm/entry/dependenciesAny.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesCumSum.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +2 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +8 -2
- package/lib/esm/entry/impureFunctionsNumber.generated.js +8 -2
- package/lib/esm/entry/pureFunctionsAny.generated.js +6 -1
- package/lib/esm/entry/pureFunctionsNumber.generated.js +6 -1
- package/lib/esm/expression/embeddedDocs/construction/fraction.js +3 -3
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +2 -0
- package/lib/esm/expression/embeddedDocs/function/statistics/cumsum.js +8 -0
- package/lib/esm/expression/transform/cumsum.transform.js +48 -0
- package/lib/esm/expression/transform/sum.transform.js +1 -1
- package/lib/esm/factoriesAny.js +2 -0
- package/lib/esm/factoriesNumber.js +2 -0
- package/lib/esm/function/algebra/simplifyCore.js +2 -2
- package/lib/esm/function/statistics/cumsum.js +139 -0
- package/lib/esm/function/statistics/sum.js +1 -1
- package/lib/esm/function/string/format.js +1 -1
- package/lib/esm/type/fraction/function/fraction.js +20 -8
- package/lib/esm/utils/collection.js +1 -26
- package/lib/esm/utils/switch.js +24 -0
- package/lib/esm/version.js +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +107 -7
@@ -6,7 +6,7 @@ import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
|
|
6
6
|
* Attach a transform function to math.sum
|
7
7
|
* Adds a property transform containing the transform function.
|
8
8
|
*
|
9
|
-
* This transform changed the last `dim` parameter of function
|
9
|
+
* This transform changed the last `dim` parameter of function sum
|
10
10
|
* from one-based to zero based
|
11
11
|
*/
|
12
12
|
|
package/lib/esm/factoriesAny.js
CHANGED
@@ -221,6 +221,7 @@ export { createDivide } from './function/arithmetic/divide.js';
|
|
221
221
|
export { createDistance } from './function/geometry/distance.js';
|
222
222
|
export { createIntersect } from './function/geometry/intersect.js';
|
223
223
|
export { createSum } from './function/statistics/sum.js';
|
224
|
+
export { createCumSum } from './function/statistics/cumsum.js';
|
224
225
|
export { createMean } from './function/statistics/mean.js';
|
225
226
|
export { createMedian } from './function/statistics/median.js';
|
226
227
|
export { createMad } from './function/statistics/mad.js';
|
@@ -269,4 +270,5 @@ export { createConcatTransform } from './expression/transform/concat.transform.j
|
|
269
270
|
export { createDiffTransform } from './expression/transform/diff.transform.js';
|
270
271
|
export { createStdTransform } from './expression/transform/std.transform.js';
|
271
272
|
export { createSumTransform } from './expression/transform/sum.transform.js';
|
273
|
+
export { createCumSumTransform } from './expression/transform/cumsum.transform.js';
|
272
274
|
export { createVarianceTransform } from './expression/transform/variance.transform.js';
|
@@ -146,6 +146,7 @@ export { createProd } from './function/statistics/prod.js';
|
|
146
146
|
export { createMax } from './function/statistics/max.js';
|
147
147
|
export { createMin } from './function/statistics/min.js';
|
148
148
|
export { createSum } from './function/statistics/sum.js';
|
149
|
+
export { createCumSum } from './function/statistics/cumsum.js';
|
149
150
|
export { createMean } from './function/statistics/mean.js';
|
150
151
|
export { createMedian } from './function/statistics/median.js';
|
151
152
|
export { createMad } from './function/statistics/mad.js';
|
@@ -195,6 +196,7 @@ export var createSubsetTransform = /* #__PURE__ */factory('subset', [], () => no
|
|
195
196
|
});
|
196
197
|
export { createStdTransform } from './expression/transform/std.transform.js';
|
197
198
|
export { createSumTransform } from './expression/transform/sum.transform.js';
|
199
|
+
export { createCumSumTransform } from './expression/transform/cumsum.transform.js';
|
198
200
|
export { createVarianceTransform } from './expression/transform/variance.transform.js'; // utils
|
199
201
|
|
200
202
|
export { createClone } from './function/utils/clone.js';
|
@@ -206,9 +206,9 @@ export var createSimplifyCore = /* #__PURE__ */factory(name, dependencies, _ref
|
|
206
206
|
}
|
207
207
|
}
|
208
208
|
}
|
209
|
-
|
210
|
-
return new OperatorNode(node.op, node.fn, [_a, a1]);
|
211
209
|
}
|
210
|
+
|
211
|
+
return new OperatorNode(node.op, node.fn, [_a, a1]);
|
212
212
|
} else if (isFunctionNode(node)) {
|
213
213
|
return new FunctionNode(simplifyCore(node.fn), node.args.map(n => simplifyCore(n, options)));
|
214
214
|
} else if (isArrayNode(node)) {
|
@@ -0,0 +1,139 @@
|
|
1
|
+
import { containsCollections } from '../../utils/collection.js';
|
2
|
+
import { factory } from '../../utils/factory.js';
|
3
|
+
import { _switch } from '../../utils/switch.js';
|
4
|
+
import { improveErrorMessage } from './utils/improveErrorMessage.js';
|
5
|
+
import { arraySize } from '../../utils/array.js';
|
6
|
+
import { IndexError } from '../../error/IndexError.js';
|
7
|
+
var name = 'cumsum';
|
8
|
+
var dependencies = ['typed', 'add', 'unaryPlus'];
|
9
|
+
export var createCumSum = /* #__PURE__ */factory(name, dependencies, _ref => {
|
10
|
+
var {
|
11
|
+
typed,
|
12
|
+
add,
|
13
|
+
unaryPlus
|
14
|
+
} = _ref;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Compute the cumulative sum of a matrix or a list with values.
|
18
|
+
* In case of a (multi dimensional) array or matrix, the cumulative sums
|
19
|
+
* along a specified dimension (defaulting to the first) will be calculated.
|
20
|
+
*
|
21
|
+
* Syntax:
|
22
|
+
*
|
23
|
+
* math.cumsum(a, b, c, ...)
|
24
|
+
* math.cumsum(A)
|
25
|
+
*
|
26
|
+
* Examples:
|
27
|
+
*
|
28
|
+
* math.cumsum(2, 1, 4, 3) // returns [2, 3, 7, 10]
|
29
|
+
* math.cumsum([2, 1, 4, 3]) // returns [2, 3, 7, 10]
|
30
|
+
* math.cumsum([[1, 2], [3, 4]]) // returns [[1, 2], [4, 6]]
|
31
|
+
* math.cumsum([[1, 2], [3, 4]], 0) // returns [[1, 2], [4, 6]]
|
32
|
+
* math.cumsum([[1, 2], [3, 4]], 1) // returns [[1, 3], [3, 7]]
|
33
|
+
* math.cumsum([[2, 5], [4, 3], [1, 7]]) // returns [[2, 5], [6, 8], [7, 15]]
|
34
|
+
*
|
35
|
+
* See also:
|
36
|
+
*
|
37
|
+
* mean, median, min, max, prod, std, variance, sum
|
38
|
+
*
|
39
|
+
* @param {... *} args A single matrix or or multiple scalar values
|
40
|
+
* @return {*} The cumulative sum of all values
|
41
|
+
*/
|
42
|
+
return typed(name, {
|
43
|
+
// sum([a, b, c, d, ...])
|
44
|
+
Array: _cumsum,
|
45
|
+
Matrix: function Matrix(matrix) {
|
46
|
+
return matrix.create(_cumsum(matrix.valueOf()));
|
47
|
+
},
|
48
|
+
// sum([a, b, c, d, ...], dim)
|
49
|
+
'Array, number | BigNumber': _ncumSumDim,
|
50
|
+
'Matrix, number | BigNumber': function MatrixNumberBigNumber(matrix, dim) {
|
51
|
+
return matrix.create(_ncumSumDim(matrix.valueOf(), dim));
|
52
|
+
},
|
53
|
+
// cumsum(a, b, c, d, ...)
|
54
|
+
'...': function _(args) {
|
55
|
+
if (containsCollections(args)) {
|
56
|
+
throw new TypeError('All values expected to be scalar in function cumsum');
|
57
|
+
}
|
58
|
+
|
59
|
+
return _cumsum(args);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
/**
|
63
|
+
* Recursively calculate the cumulative sum of an n-dimensional array
|
64
|
+
* @param {Array} array
|
65
|
+
* @return {number} cumsum
|
66
|
+
* @private
|
67
|
+
*/
|
68
|
+
|
69
|
+
function _cumsum(array) {
|
70
|
+
try {
|
71
|
+
return _cumsummap(array);
|
72
|
+
} catch (err) {
|
73
|
+
throw improveErrorMessage(err, name);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
function _cumsummap(array) {
|
78
|
+
if (array.length === 0) {
|
79
|
+
return [];
|
80
|
+
}
|
81
|
+
|
82
|
+
var sums = [unaryPlus(array[0])]; // unaryPlus converts to number if need be
|
83
|
+
|
84
|
+
for (var i = 1; i < array.length; ++i) {
|
85
|
+
// Must use add below and not addScalar for the case of summing a
|
86
|
+
// 2+-dimensional array along the 0th dimension (the row vectors,
|
87
|
+
// or higher-d analogues, are literally added to each other).
|
88
|
+
sums.push(add(sums[i - 1], array[i]));
|
89
|
+
}
|
90
|
+
|
91
|
+
return sums;
|
92
|
+
}
|
93
|
+
|
94
|
+
function _ncumSumDim(array, dim) {
|
95
|
+
var size = arraySize(array);
|
96
|
+
|
97
|
+
if (dim < 0 || dim >= size.length) {
|
98
|
+
// TODO: would be more clear when throwing a DimensionError here
|
99
|
+
throw new IndexError(dim, size.length);
|
100
|
+
}
|
101
|
+
|
102
|
+
try {
|
103
|
+
return _cumsumDimensional(array, dim);
|
104
|
+
} catch (err) {
|
105
|
+
throw improveErrorMessage(err, name);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
/* Possible TODO: Refactor _reduce in collection.js to be able to work here as well */
|
109
|
+
|
110
|
+
|
111
|
+
function _cumsumDimensional(mat, dim) {
|
112
|
+
var i, ret, tran;
|
113
|
+
|
114
|
+
if (dim <= 0) {
|
115
|
+
var initialValue = mat[0][0];
|
116
|
+
|
117
|
+
if (!Array.isArray(initialValue)) {
|
118
|
+
return _cumsummap(mat);
|
119
|
+
} else {
|
120
|
+
tran = _switch(mat);
|
121
|
+
ret = [];
|
122
|
+
|
123
|
+
for (i = 0; i < tran.length; i++) {
|
124
|
+
ret[i] = _cumsumDimensional(tran[i], dim - 1);
|
125
|
+
}
|
126
|
+
|
127
|
+
return ret;
|
128
|
+
}
|
129
|
+
} else {
|
130
|
+
ret = [];
|
131
|
+
|
132
|
+
for (i = 0; i < mat.length; i++) {
|
133
|
+
ret[i] = _cumsumDimensional(mat[i], dim - 1);
|
134
|
+
}
|
135
|
+
|
136
|
+
return ret;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
});
|
@@ -29,7 +29,7 @@ export var createSum = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
29
29
|
*
|
30
30
|
* See also:
|
31
31
|
*
|
32
|
-
* mean, median, min, max, prod, std, variance
|
32
|
+
* mean, median, min, max, prod, std, variance, cumsum
|
33
33
|
*
|
34
34
|
* @param {... *} args A single matrix or or multiple scalar values
|
35
35
|
* @return {*} The sum of all values
|
@@ -112,7 +112,7 @@ export var createFormat = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
112
112
|
* // you could also use math.format inside the callback:
|
113
113
|
* // return '$' + math.format(value, {notation: 'fixed', precision: 2})
|
114
114
|
* }
|
115
|
-
* math.format([2.1, 3, 0.016], formatCurrency
|
115
|
+
* math.format([2.1, 3, 0.016], formatCurrency) // returns '[$2.10, $3.00, $0.02]'
|
116
116
|
*
|
117
117
|
* See also:
|
118
118
|
*
|
@@ -9,27 +9,39 @@ export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
9
9
|
} = _ref;
|
10
10
|
|
11
11
|
/**
|
12
|
-
* Create a fraction convert a value to a fraction.
|
12
|
+
* Create a fraction or convert a value to a fraction.
|
13
|
+
*
|
14
|
+
* With one numeric argument, produces the closest rational approximation to the
|
15
|
+
* input.
|
16
|
+
* With two arguments, the first is the numerator and the second is the denominator,
|
17
|
+
* and creates the corresponding fraction. Both numerator and denominator must be
|
18
|
+
* integers.
|
19
|
+
* With one object argument, looks for the integer numerator as the value of property
|
20
|
+
* 'n' and the integer denominator as the value of property 'd'.
|
21
|
+
* With a matrix argument, creates a matrix of the same shape with entries
|
22
|
+
* converted into fractions.
|
13
23
|
*
|
14
24
|
* Syntax:
|
25
|
+
* math.fraction(value)
|
15
26
|
* math.fraction(numerator, denominator)
|
16
27
|
* math.fraction({n: numerator, d: denominator})
|
17
|
-
* math.fraction(matrix: Array | Matrix)
|
18
|
-
* into fractions
|
28
|
+
* math.fraction(matrix: Array | Matrix)
|
19
29
|
*
|
20
30
|
* Examples:
|
21
31
|
*
|
22
|
-
* math.fraction(
|
23
|
-
* math.fraction(
|
24
|
-
* math.fraction(
|
25
|
-
* math.fraction(
|
32
|
+
* math.fraction(6.283) // returns Fraction 6283/1000
|
33
|
+
* math.fraction(1, 3) // returns Fraction 1/3
|
34
|
+
* math.fraction('2/3') // returns Fraction 2/3
|
35
|
+
* math.fraction({n: 2, d: 3}) // returns Fraction 2/3
|
36
|
+
* math.fraction([0.2, 0.25, 1.25]) // returns Array [1/5, 1/4, 5/4]
|
37
|
+
* math.fraction(4, 5.1) // throws Error: Parameters must be integer
|
26
38
|
*
|
27
39
|
* See also:
|
28
40
|
*
|
29
41
|
* bignumber, number, string, unit
|
30
42
|
*
|
31
43
|
* @param {number | string | Fraction | BigNumber | Array | Matrix} [args]
|
32
|
-
* Arguments specifying the numerator and denominator of
|
44
|
+
* Arguments specifying the value, or numerator and denominator of
|
33
45
|
* the fraction
|
34
46
|
* @return {Fraction | Array | Matrix} Returns a fraction
|
35
47
|
*/
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { isCollection, isMatrix } from './is.js';
|
2
2
|
import { IndexError } from '../error/IndexError.js';
|
3
3
|
import { arraySize } from './array.js';
|
4
|
+
import { _switch } from './switch.js';
|
4
5
|
/**
|
5
6
|
* Test whether an array contains collections
|
6
7
|
* @param {Array} array
|
@@ -127,32 +128,6 @@ function _reduce(mat, dim, callback) {
|
|
127
128
|
|
128
129
|
return ret;
|
129
130
|
}
|
130
|
-
}
|
131
|
-
/**
|
132
|
-
* Transpose a matrix
|
133
|
-
* @param {Array} mat
|
134
|
-
* @returns {Array} ret
|
135
|
-
* @private
|
136
|
-
*/
|
137
|
-
|
138
|
-
|
139
|
-
function _switch(mat) {
|
140
|
-
var I = mat.length;
|
141
|
-
var J = mat[0].length;
|
142
|
-
var i, j;
|
143
|
-
var ret = [];
|
144
|
-
|
145
|
-
for (j = 0; j < J; j++) {
|
146
|
-
var tmp = [];
|
147
|
-
|
148
|
-
for (i = 0; i < I; i++) {
|
149
|
-
tmp.push(mat[i][j]);
|
150
|
-
}
|
151
|
-
|
152
|
-
ret.push(tmp);
|
153
|
-
}
|
154
|
-
|
155
|
-
return ret;
|
156
131
|
} // TODO: document function scatter
|
157
132
|
|
158
133
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* Transpose a matrix
|
3
|
+
* @param {Array} mat
|
4
|
+
* @returns {Array} ret
|
5
|
+
* @private
|
6
|
+
*/
|
7
|
+
export function _switch(mat) {
|
8
|
+
var I = mat.length;
|
9
|
+
var J = mat[0].length;
|
10
|
+
var i, j;
|
11
|
+
var ret = [];
|
12
|
+
|
13
|
+
for (j = 0; j < J; j++) {
|
14
|
+
var tmp = [];
|
15
|
+
|
16
|
+
for (i = 0; i < I; i++) {
|
17
|
+
tmp.push(mat[i][j]);
|
18
|
+
}
|
19
|
+
|
20
|
+
ret.push(tmp);
|
21
|
+
}
|
22
|
+
|
23
|
+
return ret;
|
24
|
+
}
|
package/lib/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export var version = '10.
|
1
|
+
export var version = '10.4.0'; // Note: This file is automatically generated when building math.js.
|
2
2
|
// Changes made in this file will be overwritten.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "10.
|
3
|
+
"version": "10.4.0",
|
4
4
|
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
6
6
|
"homepage": "https://mathjs.org",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"complex.js": "^2.0.15",
|
30
30
|
"decimal.js": "^10.3.1",
|
31
31
|
"escape-latex": "^1.2.0",
|
32
|
-
"fraction.js": "^4.
|
32
|
+
"fraction.js": "^4.2.0",
|
33
33
|
"javascript-natural-sort": "^0.7.1",
|
34
34
|
"seedrandom": "^3.0.5",
|
35
35
|
"tiny-emitter": "^2.1.0",
|
package/types/index.d.ts
CHANGED
@@ -2223,6 +2223,38 @@ declare namespace math {
|
|
2223
2223
|
*/
|
2224
2224
|
quantileSeq(A: MathArray | Matrix, prob: number | BigNumber | MathArray, sorted?: boolean): number | BigNumber | Unit | MathArray;
|
2225
2225
|
|
2226
|
+
/**
|
2227
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
2228
|
+
* standard deviations is defined as the square root of the variance:
|
2229
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
2230
|
+
* matrix, the standard deviation over all elements will be calculated.
|
2231
|
+
* Optionally, the type of normalization can be specified as second
|
2232
|
+
* parameter. The parameter normalization can be one of the following
|
2233
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
2234
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
2235
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
2236
|
+
* @param a variadic argument of number to calculate standard deviation
|
2237
|
+
* @returns The standard deviation array
|
2238
|
+
*/
|
2239
|
+
std(...values: number[]): number
|
2240
|
+
/**
|
2241
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
2242
|
+
* standard deviations is defined as the square root of the variance:
|
2243
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
2244
|
+
* matrix, the standard deviation over all elements will be calculated.
|
2245
|
+
* Optionally, the type of normalization can be specified as second
|
2246
|
+
* parameter. The parameter normalization can be one of the following
|
2247
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
2248
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
2249
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
2250
|
+
* @param array A single matrix to compute standard deviation.
|
2251
|
+
* @param dimension A dimension to calculate standard deviation
|
2252
|
+
* @param normalization Determines how to normalize the variance. Choose
|
2253
|
+
* ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
|
2254
|
+
* ‘unbiased’.
|
2255
|
+
* @returns The standard deviation array
|
2256
|
+
*/
|
2257
|
+
std(array: MathArray | Matrix, dimension: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[]
|
2226
2258
|
/**
|
2227
2259
|
* Compute the standard deviation of a matrix or a list with values. The
|
2228
2260
|
* standard deviations is defined as the square root of the variance:
|
@@ -2239,7 +2271,7 @@ declare namespace math {
|
|
2239
2271
|
* ‘unbiased’.
|
2240
2272
|
* @returns The standard deviation
|
2241
2273
|
*/
|
2242
|
-
std(array: MathArray | Matrix, normalization
|
2274
|
+
std(array: MathArray | Matrix, normalization: 'unbiased' | 'uncorrected' | 'biased'): number
|
2243
2275
|
|
2244
2276
|
/**
|
2245
2277
|
* Compute the sum of a matrix or a list with values. In case of a
|
@@ -2255,6 +2287,21 @@ declare namespace math {
|
|
2255
2287
|
*/
|
2256
2288
|
sum(array: MathArray | Matrix): any;
|
2257
2289
|
|
2290
|
+
/**
|
2291
|
+
* Compute the cumulative sum of a matrix or a list with values.
|
2292
|
+
* In case of a (multi dimensional) array or matrix, the cumulative sums
|
2293
|
+
* along a specified dimension (defaulting to the first) will be calculated.
|
2294
|
+
* @param args A single matrix or multiple scalar values
|
2295
|
+
* @returns The cumulative sums of the the values.
|
2296
|
+
*/
|
2297
|
+
cumsum(...args: MathType[]): MathType[];
|
2298
|
+
/**
|
2299
|
+
* @param array A single matrix
|
2300
|
+
* @param dim The dimension along which to sum (defaults to 0)
|
2301
|
+
* @returns The cumulative sums along the given dimension
|
2302
|
+
*/
|
2303
|
+
cumsum(array: MathArray | Matrix, dim?: number): MathArray | Matrix;
|
2304
|
+
|
2258
2305
|
/**
|
2259
2306
|
* Compute the variance of a matrix or a list with values. In case of a
|
2260
2307
|
* (multi dimensional) array or matrix, the variance over all elements
|
@@ -2269,7 +2316,26 @@ declare namespace math {
|
|
2269
2316
|
* @param args A single matrix or multiple scalar values
|
2270
2317
|
* @returns The variance
|
2271
2318
|
*/
|
2272
|
-
variance(...args: Array<number | BigNumber | Fraction>):
|
2319
|
+
variance(...args: Array<number | BigNumber | Fraction>): number;
|
2320
|
+
/**
|
2321
|
+
* Compute the variance of a matrix or a list with values. In case of a
|
2322
|
+
* (multi dimensional) array or matrix, the variance over all elements
|
2323
|
+
* will be calculated. Optionally, the type of normalization can be
|
2324
|
+
* specified as second parameter. The parameter normalization can be one
|
2325
|
+
* of the following values: 'unbiased' (default) The sum of squared
|
2326
|
+
* errors is divided by (n - 1) 'uncorrected' The sum of squared errors
|
2327
|
+
* is divided by n 'biased' The sum of squared errors is divided by (n +
|
2328
|
+
* 1) Note that older browser may not like the variable name var. In
|
2329
|
+
* that case, the function can be called as math['var'](...) instead of
|
2330
|
+
* math.variance(...).
|
2331
|
+
* @param array A matrix to compute variance.
|
2332
|
+
* @param dimension A dimension to compute variance on
|
2333
|
+
* @param normalization normalization Determines how to normalize the
|
2334
|
+
* variance. Choose ‘unbiased’ (default), ‘uncorrected’, or ‘biased’.
|
2335
|
+
* Default value: ‘unbiased’.
|
2336
|
+
* @returns variance matrix.
|
2337
|
+
*/
|
2338
|
+
variance(array: MathArray | Matrix, dimension: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[];
|
2273
2339
|
/**
|
2274
2340
|
* @param array A single matrix
|
2275
2341
|
* @param normalization normalization Determines how to normalize the
|
@@ -2277,7 +2343,7 @@ declare namespace math {
|
|
2277
2343
|
* Default value: ‘unbiased’.
|
2278
2344
|
* @returns The variance
|
2279
2345
|
*/
|
2280
|
-
variance(array: MathArray | Matrix, normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
2346
|
+
variance(array: MathArray | Matrix, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number;
|
2281
2347
|
|
2282
2348
|
/*************************************************************************
|
2283
2349
|
* String functions
|
@@ -4706,7 +4772,24 @@ declare namespace math {
|
|
4706
4772
|
* @param sorted =false is data sorted in ascending order
|
4707
4773
|
*/
|
4708
4774
|
quantileSeq(prob: number | BigNumber | MathArray, sorted?: boolean): MathJsChain;
|
4709
|
-
|
4775
|
+
/**
|
4776
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
4777
|
+
* standard deviations is defined as the square root of the variance:
|
4778
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
4779
|
+
* matrix, the standard deviation over all elements will be calculated.
|
4780
|
+
* Optionally, the type of normalization can be specified as second
|
4781
|
+
* parameter. The parameter normalization can be one of the following
|
4782
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
4783
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
4784
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
4785
|
+
* @param array A single matrix or multiple scalar values
|
4786
|
+
* @param dim A dimension to compute standard deviation.
|
4787
|
+
* @param normalization Determines how to normalize the variance. Choose
|
4788
|
+
* ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
|
4789
|
+
* ‘unbiased’.
|
4790
|
+
* @returns The standard deviation
|
4791
|
+
*/
|
4792
|
+
std(dim: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4710
4793
|
/**
|
4711
4794
|
* Compute the standard deviation of a matrix or a list with values. The
|
4712
4795
|
* standard deviations is defined as the square root of the variance:
|
@@ -4723,7 +4806,7 @@ declare namespace math {
|
|
4723
4806
|
* ‘unbiased’.
|
4724
4807
|
* @returns The standard deviation
|
4725
4808
|
*/
|
4726
|
-
std(normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
4809
|
+
std(normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4727
4810
|
|
4728
4811
|
/**
|
4729
4812
|
* Compute the sum of a matrix or a list with values. In case of a
|
@@ -4731,7 +4814,24 @@ declare namespace math {
|
|
4731
4814
|
* calculated.
|
4732
4815
|
*/
|
4733
4816
|
sum(): MathJsChain;
|
4734
|
-
|
4817
|
+
/**
|
4818
|
+
* Compute the variance of a matrix or a list with values. In case of a
|
4819
|
+
* (multi dimensional) array or matrix, the variance over all elements
|
4820
|
+
* will be calculated. Optionally, the type of normalization can be
|
4821
|
+
* specified as second parameter. The parameter normalization can be one
|
4822
|
+
* of the following values: 'unbiased' (default) The sum of squared
|
4823
|
+
* errors is divided by (n - 1) 'uncorrected' The sum of squared errors
|
4824
|
+
* is divided by n 'biased' The sum of squared errors is divided by (n +
|
4825
|
+
* 1) Note that older browser may not like the variable name var. In
|
4826
|
+
* that case, the function can be called as math['var'](...) instead of
|
4827
|
+
* math.variance(...).
|
4828
|
+
* @param dim a dimension to compute variance.
|
4829
|
+
* @param normalization normalization Determines how to normalize the
|
4830
|
+
* variance. Choose ‘unbiased’ (default), ‘uncorrected’, or ‘biased’.
|
4831
|
+
* Default value: ‘unbiased’.
|
4832
|
+
* @returns The variance
|
4833
|
+
*/
|
4834
|
+
variance(dim: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4735
4835
|
/**
|
4736
4836
|
* Compute the variance of a matrix or a list with values. In case of a
|
4737
4837
|
* (multi dimensional) array or matrix, the variance over all elements
|
@@ -4748,7 +4848,7 @@ declare namespace math {
|
|
4748
4848
|
* Default value: ‘unbiased’.
|
4749
4849
|
* @returns The variance
|
4750
4850
|
*/
|
4751
|
-
variance(normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
4851
|
+
variance(normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4752
4852
|
|
4753
4853
|
/*************************************************************************
|
4754
4854
|
* String functions
|