@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,75 @@
|
|
|
1
|
+
import { IBasicFormula } from '../common/index';
|
|
2
|
+
import { FormulaOwner } from './formula-owner';
|
|
3
|
+
import { StatisticalSampleBase } from './statistical-sample-base';
|
|
4
|
+
/**
|
|
5
|
+
* Covariance, correlation, and regression slope/intercept between paired data sets.
|
|
6
|
+
*
|
|
7
|
+
* Registered functions: CORREL, COVAR, PEARSON, FORECAST, STEYX.
|
|
8
|
+
*
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export declare class StatisticalCorrelationFormulas 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 regressionStats;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the correlation coefficient between two data sets.
|
|
22
|
+
*
|
|
23
|
+
* Excel: `CORREL(...)`.
|
|
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('=CORREL(1)');
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
ComputeCORREL(...args: string[]): string | number;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the Pearson product moment correlation coefficient.
|
|
37
|
+
*
|
|
38
|
+
* Excel: `PEARSON(...)`.
|
|
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
|
+
ComputePEARSON(...args: string[]): string | number;
|
|
45
|
+
/**
|
|
46
|
+
* Returns covariance, the average of the products of paired deviations.
|
|
47
|
+
*
|
|
48
|
+
* Excel: `COVAR(...)`.
|
|
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
|
+
ComputeCOVAR(...args: string[]): string | number;
|
|
55
|
+
/**
|
|
56
|
+
* Returns a value along a linear trend.
|
|
57
|
+
*
|
|
58
|
+
* Excel: `FORECAST(...)`.
|
|
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
|
+
ComputeFORECAST(...args: string[]): string | number;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the standard error of the predicted y-value for each x in the regression.
|
|
67
|
+
*
|
|
68
|
+
* Excel: `STEYX(...)`.
|
|
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
|
+
ComputeSTEYX(...args: string[]): string | number;
|
|
75
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Covariance, correlation, and regression slope/intercept between paired data sets.
|
|
19
|
+
*
|
|
20
|
+
* Registered functions: CORREL, COVAR, PEARSON, FORECAST, STEYX.
|
|
21
|
+
*
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
var StatisticalCorrelationFormulas = /** @class */ (function (_super) {
|
|
25
|
+
__extends(StatisticalCorrelationFormulas, _super);
|
|
26
|
+
/**
|
|
27
|
+
* @hidden
|
|
28
|
+
* @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
|
|
29
|
+
*/
|
|
30
|
+
function StatisticalCorrelationFormulas(owner) {
|
|
31
|
+
var _this = _super.call(this, owner) || this;
|
|
32
|
+
/** Formula definitions registered with {@link BasicFormulas}. */
|
|
33
|
+
_this.formulas = [
|
|
34
|
+
{ formulaName: 'CORREL', category: 'Statistical', description: 'Returns the correlation coefficient between two data sets.' },
|
|
35
|
+
{ formulaName: 'COVAR', category: 'Statistical', description: 'Returns covariance, the average of the products of paired deviations.' },
|
|
36
|
+
{ formulaName: 'PEARSON', category: 'Statistical', description: 'Returns the Pearson product moment correlation coefficient.' },
|
|
37
|
+
{ formulaName: 'FORECAST', category: 'Statistical', description: 'Returns a value along a linear trend.' },
|
|
38
|
+
{ formulaName: 'STEYX', category: 'Statistical', description: 'Returns the standard error of the predicted y-value for each x in the regression.' }
|
|
39
|
+
];
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
StatisticalCorrelationFormulas.prototype.regressionStats = function (args) {
|
|
43
|
+
var errCollection = this.parent.getErrorStrings();
|
|
44
|
+
if (isNullOrUndefined(args) || args.length !== 2) {
|
|
45
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
46
|
+
}
|
|
47
|
+
var pair = this.collectPair(args);
|
|
48
|
+
if (typeof pair === 'string') {
|
|
49
|
+
return pair;
|
|
50
|
+
}
|
|
51
|
+
var x = pair.x, y = pair.y;
|
|
52
|
+
if (x.length < 2) {
|
|
53
|
+
return errCollection[CommonErrors.DivZero];
|
|
54
|
+
}
|
|
55
|
+
var meanX = this.mean(x);
|
|
56
|
+
var meanY = this.mean(y);
|
|
57
|
+
var sxx = 0;
|
|
58
|
+
var syy = 0;
|
|
59
|
+
var sxy = 0;
|
|
60
|
+
for (var i = 0; i < x.length; i++) {
|
|
61
|
+
var dx = x[i] - meanX;
|
|
62
|
+
var dy = y[i] - meanY;
|
|
63
|
+
sxx += dx * dx;
|
|
64
|
+
syy += dy * dy;
|
|
65
|
+
sxy += dx * dy;
|
|
66
|
+
}
|
|
67
|
+
return { n: x.length, meanX: meanX, meanY: meanY, sxx: sxx, syy: syy, sxy: sxy };
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Returns the correlation coefficient between two data sets.
|
|
71
|
+
*
|
|
72
|
+
* Excel: `CORREL(...)`.
|
|
73
|
+
*
|
|
74
|
+
* @hidden
|
|
75
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
76
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* engine.computeFormula('=CORREL(1)');
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
StatisticalCorrelationFormulas.prototype.ComputeCORREL = function () {
|
|
84
|
+
var args = [];
|
|
85
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
86
|
+
args[_i] = arguments[_i];
|
|
87
|
+
}
|
|
88
|
+
var errCollection = this.parent.getErrorStrings();
|
|
89
|
+
var stats = this.regressionStats(args);
|
|
90
|
+
if (typeof stats === 'string') {
|
|
91
|
+
return stats;
|
|
92
|
+
}
|
|
93
|
+
if (stats.sxx === 0 || stats.syy === 0) {
|
|
94
|
+
return errCollection[CommonErrors.DivZero];
|
|
95
|
+
}
|
|
96
|
+
return (stats.sxy / Math.sqrt(stats.sxx * stats.syy)).toString();
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Returns the Pearson product moment correlation coefficient.
|
|
100
|
+
*
|
|
101
|
+
* Excel: `PEARSON(...)`.
|
|
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
|
+
StatisticalCorrelationFormulas.prototype.ComputePEARSON = function () {
|
|
108
|
+
var args = [];
|
|
109
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
110
|
+
args[_i] = arguments[_i];
|
|
111
|
+
}
|
|
112
|
+
return this.ComputeCORREL.apply(this, args);
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Returns covariance, the average of the products of paired deviations.
|
|
116
|
+
*
|
|
117
|
+
* Excel: `COVAR(...)`.
|
|
118
|
+
*
|
|
119
|
+
* @hidden
|
|
120
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
121
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
122
|
+
*/
|
|
123
|
+
StatisticalCorrelationFormulas.prototype.ComputeCOVAR = function () {
|
|
124
|
+
var args = [];
|
|
125
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
126
|
+
args[_i] = arguments[_i];
|
|
127
|
+
}
|
|
128
|
+
var errCollection = this.parent.getErrorStrings();
|
|
129
|
+
var stats = this.regressionStats(args);
|
|
130
|
+
if (typeof stats === 'string') {
|
|
131
|
+
return stats;
|
|
132
|
+
}
|
|
133
|
+
if (stats.n < 2) {
|
|
134
|
+
return errCollection[CommonErrors.DivZero];
|
|
135
|
+
}
|
|
136
|
+
return (stats.sxy / (stats.n - 1)).toString();
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Returns a value along a linear trend.
|
|
140
|
+
*
|
|
141
|
+
* Excel: `FORECAST(...)`.
|
|
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
|
+
StatisticalCorrelationFormulas.prototype.ComputeFORECAST = function () {
|
|
148
|
+
var args = [];
|
|
149
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
150
|
+
args[_i] = arguments[_i];
|
|
151
|
+
}
|
|
152
|
+
var errCollection = this.parent.getErrorStrings();
|
|
153
|
+
if (isNullOrUndefined(args) || args.length !== 3) {
|
|
154
|
+
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
155
|
+
}
|
|
156
|
+
var xVal = this.resolveNumberArg(args[0]);
|
|
157
|
+
if (typeof xVal === 'string') {
|
|
158
|
+
return xVal;
|
|
159
|
+
}
|
|
160
|
+
var stats = this.regressionStats([args[2], args[1]]);
|
|
161
|
+
if (typeof stats === 'string') {
|
|
162
|
+
return stats;
|
|
163
|
+
}
|
|
164
|
+
if (stats.sxx === 0) {
|
|
165
|
+
return errCollection[CommonErrors.DivZero];
|
|
166
|
+
}
|
|
167
|
+
var slope = stats.sxy / stats.sxx;
|
|
168
|
+
var intercept = stats.meanY - slope * stats.meanX;
|
|
169
|
+
return (intercept + slope * xVal).toString();
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Returns the standard error of the predicted y-value for each x in the regression.
|
|
173
|
+
*
|
|
174
|
+
* Excel: `STEYX(...)`.
|
|
175
|
+
*
|
|
176
|
+
* @hidden
|
|
177
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
178
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
179
|
+
*/
|
|
180
|
+
StatisticalCorrelationFormulas.prototype.ComputeSTEYX = function () {
|
|
181
|
+
var args = [];
|
|
182
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
183
|
+
args[_i] = arguments[_i];
|
|
184
|
+
}
|
|
185
|
+
var errCollection = this.parent.getErrorStrings();
|
|
186
|
+
var stats = this.regressionStats([args[1], args[0]]);
|
|
187
|
+
if (typeof stats === 'string') {
|
|
188
|
+
return stats;
|
|
189
|
+
}
|
|
190
|
+
if (stats.n <= 2 || stats.sxx === 0) {
|
|
191
|
+
return errCollection[CommonErrors.DivZero];
|
|
192
|
+
}
|
|
193
|
+
var ssRes = stats.syy - (stats.sxy * stats.sxy) / stats.sxx;
|
|
194
|
+
return Math.sqrt(ssRes / (stats.n - 2)).toString();
|
|
195
|
+
};
|
|
196
|
+
return StatisticalCorrelationFormulas;
|
|
197
|
+
}(StatisticalSampleBase));
|
|
198
|
+
export { StatisticalCorrelationFormulas };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { IBasicFormula } from '../common/index';
|
|
2
|
+
import { FormulaOwner } from './formula-owner';
|
|
3
|
+
import { FormulaModuleBase } from './formula-module-base';
|
|
4
|
+
/**
|
|
5
|
+
* Variability measures: variance, standard deviation, and average deviation for samples and populations.
|
|
6
|
+
*
|
|
7
|
+
* Registered functions: STDEV, STDEVP, VAR, VARP, MODE, RANK, MAXA, MINA.
|
|
8
|
+
*
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export declare class StatisticalDispersionFormulas extends FormulaModuleBase {
|
|
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 collectSample;
|
|
20
|
+
private variance;
|
|
21
|
+
/**
|
|
22
|
+
* Estimates standard deviation based on a sample.
|
|
23
|
+
*
|
|
24
|
+
* Excel: `STDEV(...)`.
|
|
25
|
+
*
|
|
26
|
+
* @hidden
|
|
27
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
28
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* engine.computeFormula('=STDEV(1)');
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
ComputeSTDEV(...args: string[]): string | number;
|
|
36
|
+
/**
|
|
37
|
+
* Calculates standard deviation based on the entire population.
|
|
38
|
+
*
|
|
39
|
+
* Excel: `STDEVP(...)`.
|
|
40
|
+
*
|
|
41
|
+
* @hidden
|
|
42
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
43
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
44
|
+
*/
|
|
45
|
+
ComputeSTDEVP(...args: string[]): string | number;
|
|
46
|
+
/**
|
|
47
|
+
* Estimates variance based on a sample.
|
|
48
|
+
*
|
|
49
|
+
* Excel: `VAR(...)`.
|
|
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
|
+
ComputeVAR(...args: string[]): string | number;
|
|
56
|
+
/**
|
|
57
|
+
* Calculates variance based on the entire population.
|
|
58
|
+
*
|
|
59
|
+
* Excel: `VARP(...)`.
|
|
60
|
+
*
|
|
61
|
+
* @hidden
|
|
62
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
63
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
64
|
+
*/
|
|
65
|
+
ComputeVARP(...args: string[]): string | number;
|
|
66
|
+
private stdevVar;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the most common value in a data set.
|
|
69
|
+
*
|
|
70
|
+
* Excel: `MODE(...)`.
|
|
71
|
+
*
|
|
72
|
+
* @hidden
|
|
73
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
74
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
75
|
+
*/
|
|
76
|
+
ComputeMODE(...args: string[]): string | number;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the rank of a number in a list of numbers.
|
|
79
|
+
*
|
|
80
|
+
* Excel: `RANK(...)`.
|
|
81
|
+
*
|
|
82
|
+
* @hidden
|
|
83
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
84
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
85
|
+
*/
|
|
86
|
+
ComputeRANK(...args: string[]): string | number;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the maximum value in a list of arguments, including text and logicals.
|
|
89
|
+
*
|
|
90
|
+
* Excel: `MAXA(...)`.
|
|
91
|
+
*
|
|
92
|
+
* @hidden
|
|
93
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
94
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
95
|
+
*/
|
|
96
|
+
ComputeMAXA(...args: string[]): string | number;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the minimum value in a list of arguments, including text and logicals.
|
|
99
|
+
*
|
|
100
|
+
* Excel: `MINA(...)`.
|
|
101
|
+
*
|
|
102
|
+
* @hidden
|
|
103
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
104
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
105
|
+
*/
|
|
106
|
+
ComputeMINA(...args: string[]): string | number;
|
|
107
|
+
private minMaxA;
|
|
108
|
+
}
|