@syncfusion/ej2-calculate 35.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +263 -0
- package/README.md +132 -0
- package/base.d.ts +4 -0
- package/base.js +4 -0
- package/common.d.ts +4 -0
- package/common.js +4 -0
- package/dist/ej2-calculate.umd.min.js +11 -0
- package/dist/ej2-calculate.umd.min.js.map +1 -0
- package/dist/es6/ej2-calculate.es2015.js +24801 -0
- package/dist/es6/ej2-calculate.es2015.js.map +1 -0
- package/dist/es6/ej2-calculate.es5.js +27229 -0
- package/dist/es6/ej2-calculate.es5.js.map +1 -0
- package/dist/global/ej2-calculate.min.js +11 -0
- package/dist/global/ej2-calculate.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/formulas.d.ts +4 -0
- package/formulas.js +4 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +30 -0
- package/src/base/calculate-model.d.ts +4 -0
- package/src/base/calculate-model.js +0 -0
- package/src/base/calculate.d.ts +1105 -0
- package/src/base/calculate.js +4720 -0
- package/src/base/index.d.ts +8 -0
- package/src/base/index.js +7 -0
- package/src/base/parser.d.ts +208 -0
- package/src/base/parser.js +1512 -0
- package/src/common/address.d.ts +59 -0
- package/src/common/address.js +96 -0
- package/src/common/cell-ref.d.ts +32 -0
- package/src/common/cell-ref.js +112 -0
- package/src/common/common.d.ts +44 -0
- package/src/common/common.js +134 -0
- package/src/common/enum.d.ts +94 -0
- package/src/common/enum.js +97 -0
- package/src/common/index.d.ts +9 -0
- package/src/common/index.js +8 -0
- package/src/common/interface.d.ts +122 -0
- package/src/common/interface.js +0 -0
- package/src/common/l10n.d.ts +24 -0
- package/src/common/l10n.js +54 -0
- package/src/common/number-date.d.ts +26 -0
- package/src/common/number-date.js +38 -0
- package/src/common/sheet-info.d.ts +10 -0
- package/src/common/sheet-info.js +17 -0
- package/src/common/sort.d.ts +17 -0
- package/src/common/sort.js +44 -0
- package/src/formulas/array.d.ts +47 -0
- package/src/formulas/array.js +718 -0
- package/src/formulas/basic.d.ts +47 -0
- package/src/formulas/basic.js +181 -0
- package/src/formulas/complex-numbers.d.ts +207 -0
- package/src/formulas/complex-numbers.js +549 -0
- package/src/formulas/database.d.ts +152 -0
- package/src/formulas/database.js +579 -0
- package/src/formulas/date-time-extra.d.ts +97 -0
- package/src/formulas/date-time-extra.js +415 -0
- package/src/formulas/date-time-intl.d.ts +57 -0
- package/src/formulas/date-time-intl.js +309 -0
- package/src/formulas/date-time.d.ts +164 -0
- package/src/formulas/date-time.js +1021 -0
- package/src/formulas/engineering-base.d.ts +150 -0
- package/src/formulas/engineering-base.js +404 -0
- package/src/formulas/engineering-bessel.d.ts +65 -0
- package/src/formulas/engineering-bessel.js +167 -0
- package/src/formulas/engineering-convert.d.ts +35 -0
- package/src/formulas/engineering-convert.js +120 -0
- package/src/formulas/engineering-misc.d.ts +64 -0
- package/src/formulas/engineering-misc.js +168 -0
- package/src/formulas/financial-amortization-ecma.d.ts +87 -0
- package/src/formulas/financial-amortization-ecma.js +288 -0
- package/src/formulas/financial-annuity.d.ts +104 -0
- package/src/formulas/financial-annuity.js +419 -0
- package/src/formulas/financial-bond-helpers.d.ts +106 -0
- package/src/formulas/financial-bond-helpers.js +190 -0
- package/src/formulas/financial-cashflow.d.ts +47 -0
- package/src/formulas/financial-cashflow.js +203 -0
- package/src/formulas/financial-coupons.d.ts +227 -0
- package/src/formulas/financial-coupons.js +810 -0
- package/src/formulas/financial-depreciation.d.ts +64 -0
- package/src/formulas/financial-depreciation.js +247 -0
- package/src/formulas/financial-rates.d.ts +54 -0
- package/src/formulas/financial-rates.js +140 -0
- package/src/formulas/financial-securities.d.ts +126 -0
- package/src/formulas/financial-securities.js +488 -0
- package/src/formulas/formula-math-helpers.d.ts +212 -0
- package/src/formulas/formula-math-helpers.js +599 -0
- package/src/formulas/formula-module-base.d.ts +54 -0
- package/src/formulas/formula-module-base.js +125 -0
- package/src/formulas/formula-owner.d.ts +17 -0
- package/src/formulas/formula-owner.js +0 -0
- package/src/formulas/index.d.ts +68 -0
- package/src/formulas/index.js +67 -0
- package/src/formulas/information-advanced.d.ts +44 -0
- package/src/formulas/information-advanced.js +157 -0
- package/src/formulas/information-ecma.d.ts +33 -0
- package/src/formulas/information-ecma.js +88 -0
- package/src/formulas/information-extra.d.ts +146 -0
- package/src/formulas/information-extra.js +351 -0
- package/src/formulas/information.d.ts +34 -0
- package/src/formulas/information.js +78 -0
- package/src/formulas/logical-extra.d.ts +75 -0
- package/src/formulas/logical-extra.js +217 -0
- package/src/formulas/logical.d.ts +83 -0
- package/src/formulas/logical.js +296 -0
- package/src/formulas/lookup-array.d.ts +98 -0
- package/src/formulas/lookup-array.js +364 -0
- package/src/formulas/lookup-ref-extra.d.ts +64 -0
- package/src/formulas/lookup-ref-extra.js +180 -0
- package/src/formulas/lookup-ref.d.ts +84 -0
- package/src/formulas/lookup-ref.js +263 -0
- package/src/formulas/lookup.d.ts +114 -0
- package/src/formulas/lookup.js +881 -0
- package/src/formulas/math-aggregate.d.ts +74 -0
- package/src/formulas/math-aggregate.js +376 -0
- package/src/formulas/math-ceiling-ecma.d.ts +42 -0
- package/src/formulas/math-ceiling-ecma.js +123 -0
- package/src/formulas/math-combinatorics.d.ts +75 -0
- package/src/formulas/math-combinatorics.js +290 -0
- package/src/formulas/math-misc.d.ts +164 -0
- package/src/formulas/math-misc.js +889 -0
- package/src/formulas/math-number.d.ts +76 -0
- package/src/formulas/math-number.js +261 -0
- package/src/formulas/math-rounding.d.ts +115 -0
- package/src/formulas/math-rounding.js +728 -0
- package/src/formulas/math-trig-hyperbolic.d.ts +55 -0
- package/src/formulas/math-trig-hyperbolic.js +113 -0
- package/src/formulas/math-trig.d.ts +165 -0
- package/src/formulas/math-trig.js +334 -0
- package/src/formulas/matrix-base.d.ts +13 -0
- package/src/formulas/matrix-base.js +169 -0
- package/src/formulas/matrix.d.ts +64 -0
- package/src/formulas/matrix.js +161 -0
- package/src/formulas/regression-ecma.d.ts +66 -0
- package/src/formulas/regression-ecma.js +234 -0
- package/src/formulas/statistical-advanced.d.ts +125 -0
- package/src/formulas/statistical-advanced.js +756 -0
- package/src/formulas/statistical-correlation.d.ts +75 -0
- package/src/formulas/statistical-correlation.js +198 -0
- package/src/formulas/statistical-dispersion.d.ts +108 -0
- package/src/formulas/statistical-dispersion.js +337 -0
- package/src/formulas/statistical-distribution-extended.d.ts +176 -0
- package/src/formulas/statistical-distribution-extended.js +668 -0
- package/src/formulas/statistical-distribution.d.ts +104 -0
- package/src/formulas/statistical-distribution.js +368 -0
- package/src/formulas/statistical-ecma.d.ts +95 -0
- package/src/formulas/statistical-ecma.js +392 -0
- package/src/formulas/statistical-extended.d.ts +136 -0
- package/src/formulas/statistical-extended.js +340 -0
- package/src/formulas/statistical-ifs.d.ts +46 -0
- package/src/formulas/statistical-ifs.js +180 -0
- package/src/formulas/statistical-moments.d.ts +84 -0
- package/src/formulas/statistical-moments.js +269 -0
- package/src/formulas/statistical-percentile.d.ts +56 -0
- package/src/formulas/statistical-percentile.js +195 -0
- package/src/formulas/statistical-sample-base.d.ts +14 -0
- package/src/formulas/statistical-sample-base.js +124 -0
- package/src/formulas/statistical.d.ts +135 -0
- package/src/formulas/statistical.js +542 -0
- package/src/formulas/text-advanced.d.ts +64 -0
- package/src/formulas/text-advanced.js +222 -0
- package/src/formulas/text-ecma.d.ts +54 -0
- package/src/formulas/text-ecma.js +106 -0
- package/src/formulas/text-extra.d.ts +216 -0
- package/src/formulas/text-extra.js +657 -0
- package/src/formulas/text.d.ts +125 -0
- package/src/formulas/text.js +628 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +14 -0
- package/tslint.json +111 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
import { FormulasErrorsStrings, CommonErrors } from '../common/index';
|
|
15
|
+
import { isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
16
|
+
import { FormulaModuleBase } from './formula-module-base';
|
|
17
|
+
/**
|
|
18
|
+
* Variability measures: variance, standard deviation, and average deviation for samples and populations.
|
|
19
|
+
*
|
|
20
|
+
* Registered functions: STDEV, STDEVP, VAR, VARP, MODE, RANK, MAXA, MINA.
|
|
21
|
+
*
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
var StatisticalDispersionFormulas = /** @class */ (function (_super) {
|
|
25
|
+
__extends(StatisticalDispersionFormulas, _super);
|
|
26
|
+
/**
|
|
27
|
+
* @hidden
|
|
28
|
+
* @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
|
|
29
|
+
*/
|
|
30
|
+
function StatisticalDispersionFormulas(owner) {
|
|
31
|
+
var _this = _super.call(this, owner) || this;
|
|
32
|
+
/** Formula definitions registered with {@link BasicFormulas}. */
|
|
33
|
+
_this.formulas = [
|
|
34
|
+
{ formulaName: 'STDEV', category: 'Statistical', description: 'Estimates standard deviation based on a sample.' },
|
|
35
|
+
{ formulaName: 'STDEVP', category: 'Statistical', description: 'Calculates standard deviation based on the entire population.' },
|
|
36
|
+
{ formulaName: 'VAR', category: 'Statistical', description: 'Estimates variance based on a sample.' },
|
|
37
|
+
{ formulaName: 'VARP', category: 'Statistical', description: 'Calculates variance based on the entire population.' },
|
|
38
|
+
{ formulaName: 'MODE', category: 'Statistical', description: 'Returns the most common value in a data set.' },
|
|
39
|
+
{ formulaName: 'RANK', category: 'Statistical', description: 'Returns the rank of a number in a list of numbers.' },
|
|
40
|
+
{ formulaName: 'MAXA', category: 'Statistical', description: 'Returns the maximum value in a list of arguments, including text and logicals.' },
|
|
41
|
+
{ formulaName: 'MINA', category: 'Statistical', description: 'Returns the minimum value in a list of arguments, including text and logicals.' }
|
|
42
|
+
];
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
StatisticalDispersionFormulas.prototype.collectSample = function (args, includeTextAsZero) {
|
|
46
|
+
var errCollection = this.parent.getErrorStrings();
|
|
47
|
+
var nums = [];
|
|
48
|
+
for (var i = 0; i < args.length; i++) {
|
|
49
|
+
var arg = args[i];
|
|
50
|
+
if (arg === '') {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (this.parent.isCellReference(arg) && arg.indexOf(':') > -1) {
|
|
54
|
+
var cells = this.parent.getCellCollection(arg);
|
|
55
|
+
var list = Array.isArray(cells) ? cells : [cells];
|
|
56
|
+
for (var c = 0; c < list.length; c++) {
|
|
57
|
+
var val = this.parent.getValueFromArg(list[c]);
|
|
58
|
+
if (errCollection.indexOf(val) > -1) {
|
|
59
|
+
return val;
|
|
60
|
+
}
|
|
61
|
+
if (val === '') {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
var upper = val.toUpperCase();
|
|
65
|
+
if (upper === this.parent.trueValue) {
|
|
66
|
+
nums.push(1);
|
|
67
|
+
}
|
|
68
|
+
else if (upper === this.parent.falseValue) {
|
|
69
|
+
nums.push(0);
|
|
70
|
+
}
|
|
71
|
+
else if (this.parent.isNumber(val)) {
|
|
72
|
+
nums.push(this.parent.parseFloat(val));
|
|
73
|
+
}
|
|
74
|
+
else if (includeTextAsZero) {
|
|
75
|
+
nums.push(0);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
var val = this.parent.getValueFromArg(arg);
|
|
81
|
+
if (errCollection.indexOf(val) > -1) {
|
|
82
|
+
return val;
|
|
83
|
+
}
|
|
84
|
+
var upper = val.toUpperCase();
|
|
85
|
+
if (upper === this.parent.trueValue) {
|
|
86
|
+
nums.push(1);
|
|
87
|
+
}
|
|
88
|
+
else if (upper === this.parent.falseValue) {
|
|
89
|
+
nums.push(0);
|
|
90
|
+
}
|
|
91
|
+
else if (val === '') {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
else if (this.parent.isNumber(this.parent.removeTics(val))) {
|
|
95
|
+
nums.push(this.parent.parseFloat(this.parent.removeTics(val)));
|
|
96
|
+
}
|
|
97
|
+
else if (includeTextAsZero) {
|
|
98
|
+
nums.push(0);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return errCollection[CommonErrors.Value];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return nums;
|
|
106
|
+
};
|
|
107
|
+
StatisticalDispersionFormulas.prototype.variance = function (nums, population) {
|
|
108
|
+
var mean = nums.reduce(function (a, b) { return a + b; }, 0) / nums.length;
|
|
109
|
+
var sumSq = 0;
|
|
110
|
+
for (var i = 0; i < nums.length; i++) {
|
|
111
|
+
var d = nums[i] - mean;
|
|
112
|
+
sumSq += d * d;
|
|
113
|
+
}
|
|
114
|
+
var denom = population ? nums.length : nums.length - 1;
|
|
115
|
+
return sumSq / denom;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Estimates standard deviation based on a sample.
|
|
119
|
+
*
|
|
120
|
+
* Excel: `STDEV(...)`.
|
|
121
|
+
*
|
|
122
|
+
* @hidden
|
|
123
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
124
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* engine.computeFormula('=STDEV(1)');
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
StatisticalDispersionFormulas.prototype.ComputeSTDEV = function () {
|
|
132
|
+
var args = [];
|
|
133
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
134
|
+
args[_i] = arguments[_i];
|
|
135
|
+
}
|
|
136
|
+
return this.stdevVar(args, false, false);
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Calculates standard deviation based on the entire population.
|
|
140
|
+
*
|
|
141
|
+
* Excel: `STDEVP(...)`.
|
|
142
|
+
*
|
|
143
|
+
* @hidden
|
|
144
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
145
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
146
|
+
*/
|
|
147
|
+
StatisticalDispersionFormulas.prototype.ComputeSTDEVP = function () {
|
|
148
|
+
var args = [];
|
|
149
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
150
|
+
args[_i] = arguments[_i];
|
|
151
|
+
}
|
|
152
|
+
return this.stdevVar(args, true, false);
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Estimates variance based on a sample.
|
|
156
|
+
*
|
|
157
|
+
* Excel: `VAR(...)`.
|
|
158
|
+
*
|
|
159
|
+
* @hidden
|
|
160
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
161
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
162
|
+
*/
|
|
163
|
+
StatisticalDispersionFormulas.prototype.ComputeVAR = function () {
|
|
164
|
+
var args = [];
|
|
165
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
166
|
+
args[_i] = arguments[_i];
|
|
167
|
+
}
|
|
168
|
+
return this.stdevVar(args, false, true);
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Calculates variance based on the entire population.
|
|
172
|
+
*
|
|
173
|
+
* Excel: `VARP(...)`.
|
|
174
|
+
*
|
|
175
|
+
* @hidden
|
|
176
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
177
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
178
|
+
*/
|
|
179
|
+
StatisticalDispersionFormulas.prototype.ComputeVARP = function () {
|
|
180
|
+
var args = [];
|
|
181
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
182
|
+
args[_i] = arguments[_i];
|
|
183
|
+
}
|
|
184
|
+
return this.stdevVar(args, true, true);
|
|
185
|
+
};
|
|
186
|
+
StatisticalDispersionFormulas.prototype.stdevVar = function (args, population, asVar) {
|
|
187
|
+
var errCollection = this.parent.getErrorStrings();
|
|
188
|
+
if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
|
|
189
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
|
|
190
|
+
}
|
|
191
|
+
var nums = this.collectSample(args, false);
|
|
192
|
+
if (typeof nums === 'string') {
|
|
193
|
+
return nums;
|
|
194
|
+
}
|
|
195
|
+
if (nums.length < (population ? 1 : 2)) {
|
|
196
|
+
return errCollection[CommonErrors.DivZero];
|
|
197
|
+
}
|
|
198
|
+
var v = this.variance(nums, population);
|
|
199
|
+
return (asVar ? v : Math.sqrt(v)).toString();
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Returns the most common value in a data set.
|
|
203
|
+
*
|
|
204
|
+
* Excel: `MODE(...)`.
|
|
205
|
+
*
|
|
206
|
+
* @hidden
|
|
207
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
208
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
209
|
+
*/
|
|
210
|
+
StatisticalDispersionFormulas.prototype.ComputeMODE = function () {
|
|
211
|
+
var args = [];
|
|
212
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
213
|
+
args[_i] = arguments[_i];
|
|
214
|
+
}
|
|
215
|
+
var errCollection = this.parent.getErrorStrings();
|
|
216
|
+
if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
|
|
217
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
|
|
218
|
+
}
|
|
219
|
+
var nums = this.collectSample(args, false);
|
|
220
|
+
if (typeof nums === 'string') {
|
|
221
|
+
return nums;
|
|
222
|
+
}
|
|
223
|
+
if (nums.length === 0) {
|
|
224
|
+
return errCollection[CommonErrors.Value];
|
|
225
|
+
}
|
|
226
|
+
var counts = new Map();
|
|
227
|
+
var best = nums[0];
|
|
228
|
+
var bestCount = 0;
|
|
229
|
+
for (var i = 0; i < nums.length; i++) {
|
|
230
|
+
var n = nums[i];
|
|
231
|
+
var c = (counts.get(n) || 0) + 1;
|
|
232
|
+
counts.set(n, c);
|
|
233
|
+
if (c > bestCount) {
|
|
234
|
+
bestCount = c;
|
|
235
|
+
best = n;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (bestCount < 2) {
|
|
239
|
+
return errCollection[CommonErrors.NA];
|
|
240
|
+
}
|
|
241
|
+
return best.toString();
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Returns the rank of a number in a list of numbers.
|
|
245
|
+
*
|
|
246
|
+
* Excel: `RANK(...)`.
|
|
247
|
+
*
|
|
248
|
+
* @hidden
|
|
249
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
250
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
251
|
+
*/
|
|
252
|
+
StatisticalDispersionFormulas.prototype.ComputeRANK = function () {
|
|
253
|
+
var args = [];
|
|
254
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
255
|
+
args[_i] = arguments[_i];
|
|
256
|
+
}
|
|
257
|
+
var errCollection = this.parent.getErrorStrings();
|
|
258
|
+
if (isNullOrUndefined(args) || args.length < 2 || args.length > 3) {
|
|
259
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
260
|
+
}
|
|
261
|
+
var number = this.resolveNumberArg(args[0]);
|
|
262
|
+
if (typeof number === 'string') {
|
|
263
|
+
return number;
|
|
264
|
+
}
|
|
265
|
+
var nums = this.collectSample([args[1]], false);
|
|
266
|
+
if (typeof nums === 'string') {
|
|
267
|
+
return nums;
|
|
268
|
+
}
|
|
269
|
+
var order = 0;
|
|
270
|
+
if (args.length === 3 && args[2] !== '') {
|
|
271
|
+
var o = this.resolveNumberArg(args[2]);
|
|
272
|
+
if (typeof o === 'string') {
|
|
273
|
+
return o;
|
|
274
|
+
}
|
|
275
|
+
order = o;
|
|
276
|
+
}
|
|
277
|
+
var sorted = nums.slice().sort(function (a, b) { return order ? a - b : b - a; });
|
|
278
|
+
var idx = sorted.indexOf(number);
|
|
279
|
+
if (idx < 0) {
|
|
280
|
+
return errCollection[CommonErrors.NA];
|
|
281
|
+
}
|
|
282
|
+
return (idx + 1).toString();
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Returns the maximum value in a list of arguments, including text and logicals.
|
|
286
|
+
*
|
|
287
|
+
* Excel: `MAXA(...)`.
|
|
288
|
+
*
|
|
289
|
+
* @hidden
|
|
290
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
291
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
292
|
+
*/
|
|
293
|
+
StatisticalDispersionFormulas.prototype.ComputeMAXA = function () {
|
|
294
|
+
var args = [];
|
|
295
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
296
|
+
args[_i] = arguments[_i];
|
|
297
|
+
}
|
|
298
|
+
return this.minMaxA(args, true);
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Returns the minimum value in a list of arguments, including text and logicals.
|
|
302
|
+
*
|
|
303
|
+
* Excel: `MINA(...)`.
|
|
304
|
+
*
|
|
305
|
+
* @hidden
|
|
306
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
307
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
308
|
+
*/
|
|
309
|
+
StatisticalDispersionFormulas.prototype.ComputeMINA = function () {
|
|
310
|
+
var args = [];
|
|
311
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
312
|
+
args[_i] = arguments[_i];
|
|
313
|
+
}
|
|
314
|
+
return this.minMaxA(args, false);
|
|
315
|
+
};
|
|
316
|
+
StatisticalDispersionFormulas.prototype.minMaxA = function (args, isMax) {
|
|
317
|
+
if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
|
|
318
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
|
|
319
|
+
}
|
|
320
|
+
var nums = this.collectSample(args, true);
|
|
321
|
+
if (typeof nums === 'string') {
|
|
322
|
+
return nums;
|
|
323
|
+
}
|
|
324
|
+
if (nums.length === 0) {
|
|
325
|
+
return '0';
|
|
326
|
+
}
|
|
327
|
+
var result = nums[0];
|
|
328
|
+
for (var i = 1; i < nums.length; i++) {
|
|
329
|
+
if (isMax ? nums[i] > result : nums[i] < result) {
|
|
330
|
+
result = nums[i];
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return result.toString();
|
|
334
|
+
};
|
|
335
|
+
return StatisticalDispersionFormulas;
|
|
336
|
+
}(FormulaModuleBase));
|
|
337
|
+
export { StatisticalDispersionFormulas };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { IBasicFormula } from '../common/index';
|
|
2
|
+
import { FormulaOwner } from './formula-owner';
|
|
3
|
+
import { StatisticalSampleBase } from './statistical-sample-base';
|
|
4
|
+
/**
|
|
5
|
+
* Extended distribution library covering additional continuous and discrete probability models.
|
|
6
|
+
*
|
|
7
|
+
* Registers 15 functions including CRITBINOM, NEGBINOMDIST, HYPGEOMDIST, WEIBULL, LOGNORMDIST, and others.
|
|
8
|
+
*
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export declare class StatisticalDistributionExtendedFormulas extends StatisticalSampleBase {
|
|
12
|
+
/** Formula definitions registered with {@link BasicFormulas}. */
|
|
13
|
+
formulas: IBasicFormula[];
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
* @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
|
|
17
|
+
*/
|
|
18
|
+
constructor(owner: FormulaOwner);
|
|
19
|
+
private parseCumulative;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the smallest value for which the cumulative binomial distribution is less than or equal to a criterion value.
|
|
22
|
+
*
|
|
23
|
+
* Excel: `CRITBINOM(...)`.
|
|
24
|
+
*
|
|
25
|
+
* @hidden
|
|
26
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
27
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* engine.computeFormula('=CRITBINOM(1)');
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
ComputeCRITBINOM(...args: string[]): string | number;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the negative binomial distribution.
|
|
37
|
+
*
|
|
38
|
+
* Excel: `NEGBINOMDIST(...)`.
|
|
39
|
+
*
|
|
40
|
+
* @hidden
|
|
41
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
42
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
43
|
+
*/
|
|
44
|
+
ComputeNEGBINOMDIST(...args: string[]): string | number;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the hypergeometric distribution.
|
|
47
|
+
*
|
|
48
|
+
* Excel: `HYPGEOMDIST(...)`.
|
|
49
|
+
*
|
|
50
|
+
* @hidden
|
|
51
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
52
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
53
|
+
*/
|
|
54
|
+
ComputeHYPGEOMDIST(...args: string[]): string | number;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the Weibull distribution.
|
|
57
|
+
*
|
|
58
|
+
* Excel: `WEIBULL(...)`.
|
|
59
|
+
*
|
|
60
|
+
* @hidden
|
|
61
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
62
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
63
|
+
*/
|
|
64
|
+
ComputeWEIBULL(...args: string[]): string | number;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the cumulative log-normal distribution.
|
|
67
|
+
*
|
|
68
|
+
* Excel: `LOGNORMDIST(...)`.
|
|
69
|
+
*
|
|
70
|
+
* @hidden
|
|
71
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
72
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
73
|
+
*/
|
|
74
|
+
ComputeLOGNORMDIST(...args: string[]): string | number;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the inverse of the log-normal cumulative distribution.
|
|
77
|
+
*
|
|
78
|
+
* Excel: `LOGINV(...)`.
|
|
79
|
+
*
|
|
80
|
+
* @hidden
|
|
81
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
82
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
83
|
+
*/
|
|
84
|
+
ComputeLOGINV(...args: string[]): string | number;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the gamma distribution.
|
|
87
|
+
*
|
|
88
|
+
* Excel: `GAMMADIST(...)`.
|
|
89
|
+
*
|
|
90
|
+
* @hidden
|
|
91
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
92
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
93
|
+
*/
|
|
94
|
+
ComputeGAMMADIST(...args: string[]): string | number;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the inverse of the gamma cumulative distribution.
|
|
97
|
+
*
|
|
98
|
+
* Excel: `GAMMAINV(...)`.
|
|
99
|
+
*
|
|
100
|
+
* @hidden
|
|
101
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
102
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
103
|
+
*/
|
|
104
|
+
ComputeGAMMAINV(...args: string[]): string | number;
|
|
105
|
+
/**
|
|
106
|
+
* Returns the one-tailed probability of the chi-squared distribution.
|
|
107
|
+
*
|
|
108
|
+
* Excel: `CHIDIST(...)`.
|
|
109
|
+
*
|
|
110
|
+
* @hidden
|
|
111
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
112
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
113
|
+
*/
|
|
114
|
+
ComputeCHIDIST(...args: string[]): string | number;
|
|
115
|
+
/**
|
|
116
|
+
* Returns the inverse of the one-tailed probability of the chi-squared distribution.
|
|
117
|
+
*
|
|
118
|
+
* Excel: `CHIINV(...)`.
|
|
119
|
+
*
|
|
120
|
+
* @hidden
|
|
121
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
122
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
123
|
+
*/
|
|
124
|
+
ComputeCHIINV(...args: string[]): string | number;
|
|
125
|
+
/**
|
|
126
|
+
* Returns the test for independence.
|
|
127
|
+
*
|
|
128
|
+
* Excel: `CHITEST(...)`.
|
|
129
|
+
*
|
|
130
|
+
* @hidden
|
|
131
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
132
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
133
|
+
*/
|
|
134
|
+
ComputeCHITEST(...args: string[]): string | number;
|
|
135
|
+
private chiSquareTest;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the F probability distribution.
|
|
138
|
+
*
|
|
139
|
+
* Excel: `FDIST(...)`.
|
|
140
|
+
*
|
|
141
|
+
* @hidden
|
|
142
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
143
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
144
|
+
*/
|
|
145
|
+
ComputeFDIST(...args: string[]): string | number;
|
|
146
|
+
/**
|
|
147
|
+
* Returns the inverse of the F probability distribution.
|
|
148
|
+
*
|
|
149
|
+
* Excel: `FINV(...)`.
|
|
150
|
+
*
|
|
151
|
+
* @hidden
|
|
152
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
153
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
154
|
+
*/
|
|
155
|
+
ComputeFINV(...args: string[]): string | number;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the one-tailed probability-value of a z-test.
|
|
158
|
+
*
|
|
159
|
+
* Excel: `ZTEST(...)`.
|
|
160
|
+
*
|
|
161
|
+
* @hidden
|
|
162
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
163
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
164
|
+
*/
|
|
165
|
+
ComputeZTEST(...args: string[]): string | number;
|
|
166
|
+
/**
|
|
167
|
+
* Returns the probability that values in a range are between two limits.
|
|
168
|
+
*
|
|
169
|
+
* Excel: `PROB(...)`.
|
|
170
|
+
*
|
|
171
|
+
* @hidden
|
|
172
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
173
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
174
|
+
*/
|
|
175
|
+
ComputePROB(...args: string[]): string | number;
|
|
176
|
+
}
|