@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,104 @@
|
|
|
1
|
+
import { IBasicFormula } from '../common/index';
|
|
2
|
+
import { FormulaOwner } from './formula-owner';
|
|
3
|
+
import { StatisticalSampleBase } from './statistical-sample-base';
|
|
4
|
+
/**
|
|
5
|
+
* Probability density and cumulative distribution functions for common statistical distributions.
|
|
6
|
+
*
|
|
7
|
+
* Registered functions: NORMDIST, NORMSDIST, NORMINV, NORMSINV, POISSON, BINOMDIST, EXPONDIST, CONFIDENCE.
|
|
8
|
+
*
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export declare class StatisticalDistributionFormulas 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
|
+
/**
|
|
20
|
+
* Returns the normal cumulative distribution.
|
|
21
|
+
*
|
|
22
|
+
* Excel: `NORMDIST(...)`.
|
|
23
|
+
*
|
|
24
|
+
* @hidden
|
|
25
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
26
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* engine.computeFormula('=NORMDIST(1)');
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
ComputeNORMDIST(...args: string[]): string | number;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the standard normal cumulative distribution.
|
|
36
|
+
*
|
|
37
|
+
* Excel: `NORMSDIST(...)`.
|
|
38
|
+
*
|
|
39
|
+
* @hidden
|
|
40
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
41
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
42
|
+
*/
|
|
43
|
+
ComputeNORMSDIST(...args: string[]): string | number;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the inverse of the normal cumulative distribution.
|
|
46
|
+
*
|
|
47
|
+
* Excel: `NORMINV(...)`.
|
|
48
|
+
*
|
|
49
|
+
* @hidden
|
|
50
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
51
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
52
|
+
*/
|
|
53
|
+
ComputeNORMINV(...args: string[]): string | number;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the inverse of the standard normal cumulative distribution.
|
|
56
|
+
*
|
|
57
|
+
* Excel: `NORMSINV(...)`.
|
|
58
|
+
*
|
|
59
|
+
* @hidden
|
|
60
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
61
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
62
|
+
*/
|
|
63
|
+
ComputeNORMSINV(...args: string[]): string | number;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the Poisson distribution.
|
|
66
|
+
*
|
|
67
|
+
* Excel: `POISSON(...)`.
|
|
68
|
+
*
|
|
69
|
+
* @hidden
|
|
70
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
71
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
72
|
+
*/
|
|
73
|
+
ComputePOISSON(...args: string[]): string | number;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the individual term binomial distribution probability.
|
|
76
|
+
*
|
|
77
|
+
* Excel: `BINOMDIST(...)`.
|
|
78
|
+
*
|
|
79
|
+
* @hidden
|
|
80
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
81
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
82
|
+
*/
|
|
83
|
+
ComputeBINOMDIST(...args: string[]): string | number;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the exponential distribution.
|
|
86
|
+
*
|
|
87
|
+
* Excel: `EXPONDIST(...)`.
|
|
88
|
+
*
|
|
89
|
+
* @hidden
|
|
90
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
91
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
92
|
+
*/
|
|
93
|
+
ComputeEXPONDIST(...args: string[]): string | number;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the confidence interval for a population mean.
|
|
96
|
+
*
|
|
97
|
+
* Excel: `CONFIDENCE(...)`.
|
|
98
|
+
*
|
|
99
|
+
* @hidden
|
|
100
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
101
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
102
|
+
*/
|
|
103
|
+
ComputeCONFIDENCE(...args: string[]): string | number;
|
|
104
|
+
}
|
|
@@ -0,0 +1,368 @@
|
|
|
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 { StatisticalSampleBase } from './statistical-sample-base';
|
|
17
|
+
import { normCDF, normInv, binomialCoeff, factorial } from './formula-math-helpers';
|
|
18
|
+
/**
|
|
19
|
+
* Probability density and cumulative distribution functions for common statistical distributions.
|
|
20
|
+
*
|
|
21
|
+
* Registered functions: NORMDIST, NORMSDIST, NORMINV, NORMSINV, POISSON, BINOMDIST, EXPONDIST, CONFIDENCE.
|
|
22
|
+
*
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
25
|
+
var StatisticalDistributionFormulas = /** @class */ (function (_super) {
|
|
26
|
+
__extends(StatisticalDistributionFormulas, _super);
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
* @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
|
|
30
|
+
*/
|
|
31
|
+
function StatisticalDistributionFormulas(owner) {
|
|
32
|
+
var _this = _super.call(this, owner) || this;
|
|
33
|
+
/** Formula definitions registered with {@link BasicFormulas}. */
|
|
34
|
+
_this.formulas = [
|
|
35
|
+
{ formulaName: 'NORMDIST', category: 'Statistical', description: 'Returns the normal cumulative distribution.' },
|
|
36
|
+
{ formulaName: 'NORMSDIST', category: 'Statistical', description: 'Returns the standard normal cumulative distribution.' },
|
|
37
|
+
{ formulaName: 'NORMINV', category: 'Statistical', description: 'Returns the inverse of the normal cumulative distribution.' },
|
|
38
|
+
{ formulaName: 'NORMSINV', category: 'Statistical', description: 'Returns the inverse of the standard normal cumulative distribution.' },
|
|
39
|
+
{ formulaName: 'POISSON', category: 'Statistical', description: 'Returns the Poisson distribution.' },
|
|
40
|
+
{ formulaName: 'BINOMDIST', category: 'Statistical', description: 'Returns the individual term binomial distribution probability.' },
|
|
41
|
+
{ formulaName: 'EXPONDIST', category: 'Statistical', description: 'Returns the exponential distribution.' },
|
|
42
|
+
{ formulaName: 'CONFIDENCE', category: 'Statistical', description: 'Returns the confidence interval for a population mean.' }
|
|
43
|
+
];
|
|
44
|
+
return _this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the normal cumulative distribution.
|
|
48
|
+
*
|
|
49
|
+
* Excel: `NORMDIST(...)`.
|
|
50
|
+
*
|
|
51
|
+
* @hidden
|
|
52
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
53
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* engine.computeFormula('=NORMDIST(1)');
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
StatisticalDistributionFormulas.prototype.ComputeNORMDIST = function () {
|
|
61
|
+
var args = [];
|
|
62
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
63
|
+
args[_i] = arguments[_i];
|
|
64
|
+
}
|
|
65
|
+
var errCollection = this.parent.getErrorStrings();
|
|
66
|
+
if (isNullOrUndefined(args) || args.length < 3 || args.length > 4) {
|
|
67
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
68
|
+
}
|
|
69
|
+
var x = this.resolveNumberArg(args[0]);
|
|
70
|
+
var mean = this.resolveNumberArg(args[1]);
|
|
71
|
+
var std = this.resolveNumberArg(args[2]);
|
|
72
|
+
if (typeof x === 'string') {
|
|
73
|
+
return x;
|
|
74
|
+
}
|
|
75
|
+
if (typeof mean === 'string') {
|
|
76
|
+
return mean;
|
|
77
|
+
}
|
|
78
|
+
if (typeof std === 'string') {
|
|
79
|
+
return std;
|
|
80
|
+
}
|
|
81
|
+
if (std <= 0) {
|
|
82
|
+
return errCollection[CommonErrors.Num];
|
|
83
|
+
}
|
|
84
|
+
var cumulative = true;
|
|
85
|
+
if (args.length === 4) {
|
|
86
|
+
var cumArg = this.resolveNumberArg(args[3]);
|
|
87
|
+
if (typeof cumArg === 'string') {
|
|
88
|
+
return cumArg;
|
|
89
|
+
}
|
|
90
|
+
cumulative = cumArg !== 0;
|
|
91
|
+
}
|
|
92
|
+
if (cumulative) {
|
|
93
|
+
return normCDF(x, mean, std).toString();
|
|
94
|
+
}
|
|
95
|
+
var z = (x - mean) / std;
|
|
96
|
+
return (Math.exp(-0.5 * z * z) / (std * Math.sqrt(2 * Math.PI))).toString();
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Returns the standard normal cumulative distribution.
|
|
100
|
+
*
|
|
101
|
+
* Excel: `NORMSDIST(...)`.
|
|
102
|
+
*
|
|
103
|
+
* @hidden
|
|
104
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
105
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
106
|
+
*/
|
|
107
|
+
StatisticalDistributionFormulas.prototype.ComputeNORMSDIST = function () {
|
|
108
|
+
var args = [];
|
|
109
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
110
|
+
args[_i] = arguments[_i];
|
|
111
|
+
}
|
|
112
|
+
if (isNullOrUndefined(args) || args.length !== 1) {
|
|
113
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
114
|
+
}
|
|
115
|
+
var z = this.resolveNumberArg(args[0]);
|
|
116
|
+
if (typeof z === 'string') {
|
|
117
|
+
return z;
|
|
118
|
+
}
|
|
119
|
+
return normCDF(z).toString();
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Returns the inverse of the normal cumulative distribution.
|
|
123
|
+
*
|
|
124
|
+
* Excel: `NORMINV(...)`.
|
|
125
|
+
*
|
|
126
|
+
* @hidden
|
|
127
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
128
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
129
|
+
*/
|
|
130
|
+
StatisticalDistributionFormulas.prototype.ComputeNORMINV = function () {
|
|
131
|
+
var args = [];
|
|
132
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
133
|
+
args[_i] = arguments[_i];
|
|
134
|
+
}
|
|
135
|
+
var errCollection = this.parent.getErrorStrings();
|
|
136
|
+
if (isNullOrUndefined(args) || args.length !== 3) {
|
|
137
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
138
|
+
}
|
|
139
|
+
var p = this.resolveNumberArg(args[0]);
|
|
140
|
+
var mean = this.resolveNumberArg(args[1]);
|
|
141
|
+
var std = this.resolveNumberArg(args[2]);
|
|
142
|
+
if (typeof p === 'string') {
|
|
143
|
+
return p;
|
|
144
|
+
}
|
|
145
|
+
if (typeof mean === 'string') {
|
|
146
|
+
return mean;
|
|
147
|
+
}
|
|
148
|
+
if (typeof std === 'string') {
|
|
149
|
+
return std;
|
|
150
|
+
}
|
|
151
|
+
var result = normInv(p, mean, std);
|
|
152
|
+
if (isNaN(result)) {
|
|
153
|
+
return errCollection[CommonErrors.Num];
|
|
154
|
+
}
|
|
155
|
+
return result.toString();
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Returns the inverse of the standard normal cumulative distribution.
|
|
159
|
+
*
|
|
160
|
+
* Excel: `NORMSINV(...)`.
|
|
161
|
+
*
|
|
162
|
+
* @hidden
|
|
163
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
164
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
165
|
+
*/
|
|
166
|
+
StatisticalDistributionFormulas.prototype.ComputeNORMSINV = function () {
|
|
167
|
+
var args = [];
|
|
168
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
169
|
+
args[_i] = arguments[_i];
|
|
170
|
+
}
|
|
171
|
+
var errCollection = this.parent.getErrorStrings();
|
|
172
|
+
if (isNullOrUndefined(args) || args.length !== 1) {
|
|
173
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
174
|
+
}
|
|
175
|
+
var p = this.resolveNumberArg(args[0]);
|
|
176
|
+
if (typeof p === 'string') {
|
|
177
|
+
return p;
|
|
178
|
+
}
|
|
179
|
+
var result = normInv(p);
|
|
180
|
+
if (isNaN(result)) {
|
|
181
|
+
return errCollection[CommonErrors.Num];
|
|
182
|
+
}
|
|
183
|
+
return result.toString();
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Returns the Poisson distribution.
|
|
187
|
+
*
|
|
188
|
+
* Excel: `POISSON(...)`.
|
|
189
|
+
*
|
|
190
|
+
* @hidden
|
|
191
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
192
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
193
|
+
*/
|
|
194
|
+
StatisticalDistributionFormulas.prototype.ComputePOISSON = function () {
|
|
195
|
+
var args = [];
|
|
196
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
197
|
+
args[_i] = arguments[_i];
|
|
198
|
+
}
|
|
199
|
+
var errCollection = this.parent.getErrorStrings();
|
|
200
|
+
if (isNullOrUndefined(args) || args.length < 2 || args.length > 3) {
|
|
201
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
202
|
+
}
|
|
203
|
+
var x = this.resolveNumberArg(args[0]);
|
|
204
|
+
var mean = this.resolveNumberArg(args[1]);
|
|
205
|
+
if (typeof x === 'string') {
|
|
206
|
+
return x;
|
|
207
|
+
}
|
|
208
|
+
if (typeof mean === 'string') {
|
|
209
|
+
return mean;
|
|
210
|
+
}
|
|
211
|
+
var k = Math.floor(x);
|
|
212
|
+
if (k < 0 || mean < 0) {
|
|
213
|
+
return errCollection[CommonErrors.Num];
|
|
214
|
+
}
|
|
215
|
+
var cumulative = true;
|
|
216
|
+
if (args.length === 3) {
|
|
217
|
+
var cumArg = this.resolveNumberArg(args[2]);
|
|
218
|
+
if (typeof cumArg === 'string') {
|
|
219
|
+
return cumArg;
|
|
220
|
+
}
|
|
221
|
+
cumulative = cumArg !== 0;
|
|
222
|
+
}
|
|
223
|
+
if (!cumulative) {
|
|
224
|
+
return (Math.exp(-mean) * Math.pow(mean, k) / factorial(k)).toString();
|
|
225
|
+
}
|
|
226
|
+
var sum = 0;
|
|
227
|
+
for (var i = 0; i <= k; i++) {
|
|
228
|
+
sum += Math.exp(-mean) * Math.pow(mean, i) / factorial(i);
|
|
229
|
+
}
|
|
230
|
+
return sum.toString();
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Returns the individual term binomial distribution probability.
|
|
234
|
+
*
|
|
235
|
+
* Excel: `BINOMDIST(...)`.
|
|
236
|
+
*
|
|
237
|
+
* @hidden
|
|
238
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
239
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
240
|
+
*/
|
|
241
|
+
StatisticalDistributionFormulas.prototype.ComputeBINOMDIST = function () {
|
|
242
|
+
var args = [];
|
|
243
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
244
|
+
args[_i] = arguments[_i];
|
|
245
|
+
}
|
|
246
|
+
var errCollection = this.parent.getErrorStrings();
|
|
247
|
+
if (isNullOrUndefined(args) || args.length < 3 || args.length > 4) {
|
|
248
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
249
|
+
}
|
|
250
|
+
var successes = this.resolveNumberArg(args[0]);
|
|
251
|
+
var trials = this.resolveNumberArg(args[1]);
|
|
252
|
+
var prob = this.resolveNumberArg(args[2]);
|
|
253
|
+
if (typeof successes === 'string') {
|
|
254
|
+
return successes;
|
|
255
|
+
}
|
|
256
|
+
if (typeof trials === 'string') {
|
|
257
|
+
return trials;
|
|
258
|
+
}
|
|
259
|
+
if (typeof prob === 'string') {
|
|
260
|
+
return prob;
|
|
261
|
+
}
|
|
262
|
+
var s = Math.floor(successes);
|
|
263
|
+
var n = Math.floor(trials);
|
|
264
|
+
if (s < 0 || n < 0 || s > n || prob < 0 || prob > 1) {
|
|
265
|
+
return errCollection[CommonErrors.Num];
|
|
266
|
+
}
|
|
267
|
+
var cumulative = true;
|
|
268
|
+
if (args.length === 4) {
|
|
269
|
+
var cumArg = this.resolveNumberArg(args[3]);
|
|
270
|
+
if (typeof cumArg === 'string') {
|
|
271
|
+
return cumArg;
|
|
272
|
+
}
|
|
273
|
+
cumulative = cumArg !== 0;
|
|
274
|
+
}
|
|
275
|
+
var pmf = binomialCoeff(n, s) * Math.pow(prob, s) * Math.pow(1 - prob, n - s);
|
|
276
|
+
if (!cumulative) {
|
|
277
|
+
return pmf.toString();
|
|
278
|
+
}
|
|
279
|
+
var sum = 0;
|
|
280
|
+
for (var i = 0; i <= s; i++) {
|
|
281
|
+
sum += binomialCoeff(n, i) * Math.pow(prob, i) * Math.pow(1 - prob, n - i);
|
|
282
|
+
}
|
|
283
|
+
return sum.toString();
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Returns the exponential distribution.
|
|
287
|
+
*
|
|
288
|
+
* Excel: `EXPONDIST(...)`.
|
|
289
|
+
*
|
|
290
|
+
* @hidden
|
|
291
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
292
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
293
|
+
*/
|
|
294
|
+
StatisticalDistributionFormulas.prototype.ComputeEXPONDIST = function () {
|
|
295
|
+
var args = [];
|
|
296
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
297
|
+
args[_i] = arguments[_i];
|
|
298
|
+
}
|
|
299
|
+
var errCollection = this.parent.getErrorStrings();
|
|
300
|
+
if (isNullOrUndefined(args) || args.length < 2 || args.length > 3) {
|
|
301
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
302
|
+
}
|
|
303
|
+
var x = this.resolveNumberArg(args[0]);
|
|
304
|
+
var lambda = this.resolveNumberArg(args[1]);
|
|
305
|
+
if (typeof x === 'string') {
|
|
306
|
+
return x;
|
|
307
|
+
}
|
|
308
|
+
if (typeof lambda === 'string') {
|
|
309
|
+
return lambda;
|
|
310
|
+
}
|
|
311
|
+
if (x < 0 || lambda <= 0) {
|
|
312
|
+
return errCollection[CommonErrors.Num];
|
|
313
|
+
}
|
|
314
|
+
var cumulative = true;
|
|
315
|
+
if (args.length === 3) {
|
|
316
|
+
var cumArg = this.resolveNumberArg(args[2]);
|
|
317
|
+
if (typeof cumArg === 'string') {
|
|
318
|
+
return cumArg;
|
|
319
|
+
}
|
|
320
|
+
cumulative = cumArg !== 0;
|
|
321
|
+
}
|
|
322
|
+
if (cumulative) {
|
|
323
|
+
return (1 - Math.exp(-lambda * x)).toString();
|
|
324
|
+
}
|
|
325
|
+
return (lambda * Math.exp(-lambda * x)).toString();
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Returns the confidence interval for a population mean.
|
|
329
|
+
*
|
|
330
|
+
* Excel: `CONFIDENCE(...)`.
|
|
331
|
+
*
|
|
332
|
+
* @hidden
|
|
333
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
334
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
335
|
+
*/
|
|
336
|
+
StatisticalDistributionFormulas.prototype.ComputeCONFIDENCE = function () {
|
|
337
|
+
var args = [];
|
|
338
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
339
|
+
args[_i] = arguments[_i];
|
|
340
|
+
}
|
|
341
|
+
var errCollection = this.parent.getErrorStrings();
|
|
342
|
+
if (isNullOrUndefined(args) || args.length !== 3) {
|
|
343
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
344
|
+
}
|
|
345
|
+
var alpha = this.resolveNumberArg(args[0]);
|
|
346
|
+
var std = this.resolveNumberArg(args[1]);
|
|
347
|
+
var size = this.resolveNumberArg(args[2]);
|
|
348
|
+
if (typeof alpha === 'string') {
|
|
349
|
+
return alpha;
|
|
350
|
+
}
|
|
351
|
+
if (typeof std === 'string') {
|
|
352
|
+
return std;
|
|
353
|
+
}
|
|
354
|
+
if (typeof size === 'string') {
|
|
355
|
+
return size;
|
|
356
|
+
}
|
|
357
|
+
if (alpha <= 0 || alpha >= 1 || std <= 0 || size < 1) {
|
|
358
|
+
return errCollection[CommonErrors.Num];
|
|
359
|
+
}
|
|
360
|
+
var z = normInv(1 - alpha / 2);
|
|
361
|
+
if (isNaN(z)) {
|
|
362
|
+
return errCollection[CommonErrors.Num];
|
|
363
|
+
}
|
|
364
|
+
return (z * std / Math.sqrt(size)).toString();
|
|
365
|
+
};
|
|
366
|
+
return StatisticalDistributionFormulas;
|
|
367
|
+
}(StatisticalSampleBase));
|
|
368
|
+
export { StatisticalDistributionFormulas };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { IBasicFormula } from '../common/index';
|
|
2
|
+
import { FormulaOwner } from './formula-owner';
|
|
3
|
+
import { StatisticalSampleBase } from './statistical-sample-base';
|
|
4
|
+
/**
|
|
5
|
+
* ECMA-376 statistical distribution and hypothesis-test functions (beta, t, F, frequency).
|
|
6
|
+
*
|
|
7
|
+
* Registered functions: BETADIST, BETAINV, TDIST, TINV, TTEST, FTEST, FREQUENCY.
|
|
8
|
+
*
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export declare class StatisticalEcmaFormulas 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
|
+
/**
|
|
20
|
+
* Returns the beta cumulative distribution function.
|
|
21
|
+
*
|
|
22
|
+
* Excel: `BETADIST(...)`.
|
|
23
|
+
*
|
|
24
|
+
* @hidden
|
|
25
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
26
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* engine.computeFormula('=BETADIST(1)');
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
ComputeBETADIST(...args: string[]): string | number;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the inverse of the beta cumulative distribution function.
|
|
36
|
+
*
|
|
37
|
+
* Excel: `BETAINV(...)`.
|
|
38
|
+
*
|
|
39
|
+
* @hidden
|
|
40
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
41
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
42
|
+
*/
|
|
43
|
+
ComputeBETAINV(...args: string[]): string | number;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the Student t-distribution.
|
|
46
|
+
*
|
|
47
|
+
* Excel: `TDIST(...)`.
|
|
48
|
+
*
|
|
49
|
+
* @hidden
|
|
50
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
51
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
52
|
+
*/
|
|
53
|
+
ComputeTDIST(...args: string[]): string | number;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the inverse of the Student t-distribution.
|
|
56
|
+
*
|
|
57
|
+
* Excel: `TINV(...)`.
|
|
58
|
+
*
|
|
59
|
+
* @hidden
|
|
60
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
61
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
62
|
+
*/
|
|
63
|
+
ComputeTINV(...args: string[]): string | number;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the probability associated with a Student t-test.
|
|
66
|
+
*
|
|
67
|
+
* Excel: `TTEST(...)`.
|
|
68
|
+
*
|
|
69
|
+
* @hidden
|
|
70
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
71
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
72
|
+
*/
|
|
73
|
+
ComputeTTEST(...args: string[]): string | number;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the result of an F-test.
|
|
76
|
+
*
|
|
77
|
+
* Excel: `FTEST(...)`.
|
|
78
|
+
*
|
|
79
|
+
* @hidden
|
|
80
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
81
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
82
|
+
*/
|
|
83
|
+
ComputeFTEST(...args: string[]): string | number;
|
|
84
|
+
private sampleVar;
|
|
85
|
+
/**
|
|
86
|
+
* Returns a frequency distribution as a vertical array (first bin when spill unavailable).
|
|
87
|
+
*
|
|
88
|
+
* Excel: `FREQUENCY(...)`.
|
|
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
|
+
ComputeFREQUENCY(...args: string[]): string | number;
|
|
95
|
+
}
|