@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.
Files changed (173) hide show
  1. package/.eslintrc.json +263 -0
  2. package/README.md +132 -0
  3. package/base.d.ts +4 -0
  4. package/base.js +4 -0
  5. package/common.d.ts +4 -0
  6. package/common.js +4 -0
  7. package/dist/ej2-calculate.umd.min.js +11 -0
  8. package/dist/ej2-calculate.umd.min.js.map +1 -0
  9. package/dist/es6/ej2-calculate.es2015.js +24801 -0
  10. package/dist/es6/ej2-calculate.es2015.js.map +1 -0
  11. package/dist/es6/ej2-calculate.es5.js +27229 -0
  12. package/dist/es6/ej2-calculate.es5.js.map +1 -0
  13. package/dist/global/ej2-calculate.min.js +11 -0
  14. package/dist/global/ej2-calculate.min.js.map +1 -0
  15. package/dist/global/index.d.ts +14 -0
  16. package/formulas.d.ts +4 -0
  17. package/formulas.js +4 -0
  18. package/index.d.ts +4 -0
  19. package/index.js +4 -0
  20. package/license +10 -0
  21. package/package.json +30 -0
  22. package/src/base/calculate-model.d.ts +4 -0
  23. package/src/base/calculate-model.js +0 -0
  24. package/src/base/calculate.d.ts +1105 -0
  25. package/src/base/calculate.js +4720 -0
  26. package/src/base/index.d.ts +8 -0
  27. package/src/base/index.js +7 -0
  28. package/src/base/parser.d.ts +208 -0
  29. package/src/base/parser.js +1512 -0
  30. package/src/common/address.d.ts +59 -0
  31. package/src/common/address.js +96 -0
  32. package/src/common/cell-ref.d.ts +32 -0
  33. package/src/common/cell-ref.js +112 -0
  34. package/src/common/common.d.ts +44 -0
  35. package/src/common/common.js +134 -0
  36. package/src/common/enum.d.ts +94 -0
  37. package/src/common/enum.js +97 -0
  38. package/src/common/index.d.ts +9 -0
  39. package/src/common/index.js +8 -0
  40. package/src/common/interface.d.ts +122 -0
  41. package/src/common/interface.js +0 -0
  42. package/src/common/l10n.d.ts +24 -0
  43. package/src/common/l10n.js +54 -0
  44. package/src/common/number-date.d.ts +26 -0
  45. package/src/common/number-date.js +38 -0
  46. package/src/common/sheet-info.d.ts +10 -0
  47. package/src/common/sheet-info.js +17 -0
  48. package/src/common/sort.d.ts +17 -0
  49. package/src/common/sort.js +44 -0
  50. package/src/formulas/array.d.ts +47 -0
  51. package/src/formulas/array.js +718 -0
  52. package/src/formulas/basic.d.ts +47 -0
  53. package/src/formulas/basic.js +181 -0
  54. package/src/formulas/complex-numbers.d.ts +207 -0
  55. package/src/formulas/complex-numbers.js +549 -0
  56. package/src/formulas/database.d.ts +152 -0
  57. package/src/formulas/database.js +579 -0
  58. package/src/formulas/date-time-extra.d.ts +97 -0
  59. package/src/formulas/date-time-extra.js +415 -0
  60. package/src/formulas/date-time-intl.d.ts +57 -0
  61. package/src/formulas/date-time-intl.js +309 -0
  62. package/src/formulas/date-time.d.ts +164 -0
  63. package/src/formulas/date-time.js +1021 -0
  64. package/src/formulas/engineering-base.d.ts +150 -0
  65. package/src/formulas/engineering-base.js +404 -0
  66. package/src/formulas/engineering-bessel.d.ts +65 -0
  67. package/src/formulas/engineering-bessel.js +167 -0
  68. package/src/formulas/engineering-convert.d.ts +35 -0
  69. package/src/formulas/engineering-convert.js +120 -0
  70. package/src/formulas/engineering-misc.d.ts +64 -0
  71. package/src/formulas/engineering-misc.js +168 -0
  72. package/src/formulas/financial-amortization-ecma.d.ts +87 -0
  73. package/src/formulas/financial-amortization-ecma.js +288 -0
  74. package/src/formulas/financial-annuity.d.ts +104 -0
  75. package/src/formulas/financial-annuity.js +419 -0
  76. package/src/formulas/financial-bond-helpers.d.ts +106 -0
  77. package/src/formulas/financial-bond-helpers.js +190 -0
  78. package/src/formulas/financial-cashflow.d.ts +47 -0
  79. package/src/formulas/financial-cashflow.js +203 -0
  80. package/src/formulas/financial-coupons.d.ts +227 -0
  81. package/src/formulas/financial-coupons.js +810 -0
  82. package/src/formulas/financial-depreciation.d.ts +64 -0
  83. package/src/formulas/financial-depreciation.js +247 -0
  84. package/src/formulas/financial-rates.d.ts +54 -0
  85. package/src/formulas/financial-rates.js +140 -0
  86. package/src/formulas/financial-securities.d.ts +126 -0
  87. package/src/formulas/financial-securities.js +488 -0
  88. package/src/formulas/formula-math-helpers.d.ts +212 -0
  89. package/src/formulas/formula-math-helpers.js +599 -0
  90. package/src/formulas/formula-module-base.d.ts +54 -0
  91. package/src/formulas/formula-module-base.js +125 -0
  92. package/src/formulas/formula-owner.d.ts +17 -0
  93. package/src/formulas/formula-owner.js +0 -0
  94. package/src/formulas/index.d.ts +68 -0
  95. package/src/formulas/index.js +67 -0
  96. package/src/formulas/information-advanced.d.ts +44 -0
  97. package/src/formulas/information-advanced.js +157 -0
  98. package/src/formulas/information-ecma.d.ts +33 -0
  99. package/src/formulas/information-ecma.js +88 -0
  100. package/src/formulas/information-extra.d.ts +146 -0
  101. package/src/formulas/information-extra.js +351 -0
  102. package/src/formulas/information.d.ts +34 -0
  103. package/src/formulas/information.js +78 -0
  104. package/src/formulas/logical-extra.d.ts +75 -0
  105. package/src/formulas/logical-extra.js +217 -0
  106. package/src/formulas/logical.d.ts +83 -0
  107. package/src/formulas/logical.js +296 -0
  108. package/src/formulas/lookup-array.d.ts +98 -0
  109. package/src/formulas/lookup-array.js +364 -0
  110. package/src/formulas/lookup-ref-extra.d.ts +64 -0
  111. package/src/formulas/lookup-ref-extra.js +180 -0
  112. package/src/formulas/lookup-ref.d.ts +84 -0
  113. package/src/formulas/lookup-ref.js +263 -0
  114. package/src/formulas/lookup.d.ts +114 -0
  115. package/src/formulas/lookup.js +881 -0
  116. package/src/formulas/math-aggregate.d.ts +74 -0
  117. package/src/formulas/math-aggregate.js +376 -0
  118. package/src/formulas/math-ceiling-ecma.d.ts +42 -0
  119. package/src/formulas/math-ceiling-ecma.js +123 -0
  120. package/src/formulas/math-combinatorics.d.ts +75 -0
  121. package/src/formulas/math-combinatorics.js +290 -0
  122. package/src/formulas/math-misc.d.ts +164 -0
  123. package/src/formulas/math-misc.js +889 -0
  124. package/src/formulas/math-number.d.ts +76 -0
  125. package/src/formulas/math-number.js +261 -0
  126. package/src/formulas/math-rounding.d.ts +115 -0
  127. package/src/formulas/math-rounding.js +728 -0
  128. package/src/formulas/math-trig-hyperbolic.d.ts +55 -0
  129. package/src/formulas/math-trig-hyperbolic.js +113 -0
  130. package/src/formulas/math-trig.d.ts +165 -0
  131. package/src/formulas/math-trig.js +334 -0
  132. package/src/formulas/matrix-base.d.ts +13 -0
  133. package/src/formulas/matrix-base.js +169 -0
  134. package/src/formulas/matrix.d.ts +64 -0
  135. package/src/formulas/matrix.js +161 -0
  136. package/src/formulas/regression-ecma.d.ts +66 -0
  137. package/src/formulas/regression-ecma.js +234 -0
  138. package/src/formulas/statistical-advanced.d.ts +125 -0
  139. package/src/formulas/statistical-advanced.js +756 -0
  140. package/src/formulas/statistical-correlation.d.ts +75 -0
  141. package/src/formulas/statistical-correlation.js +198 -0
  142. package/src/formulas/statistical-dispersion.d.ts +108 -0
  143. package/src/formulas/statistical-dispersion.js +337 -0
  144. package/src/formulas/statistical-distribution-extended.d.ts +176 -0
  145. package/src/formulas/statistical-distribution-extended.js +668 -0
  146. package/src/formulas/statistical-distribution.d.ts +104 -0
  147. package/src/formulas/statistical-distribution.js +368 -0
  148. package/src/formulas/statistical-ecma.d.ts +95 -0
  149. package/src/formulas/statistical-ecma.js +392 -0
  150. package/src/formulas/statistical-extended.d.ts +136 -0
  151. package/src/formulas/statistical-extended.js +340 -0
  152. package/src/formulas/statistical-ifs.d.ts +46 -0
  153. package/src/formulas/statistical-ifs.js +180 -0
  154. package/src/formulas/statistical-moments.d.ts +84 -0
  155. package/src/formulas/statistical-moments.js +269 -0
  156. package/src/formulas/statistical-percentile.d.ts +56 -0
  157. package/src/formulas/statistical-percentile.js +195 -0
  158. package/src/formulas/statistical-sample-base.d.ts +14 -0
  159. package/src/formulas/statistical-sample-base.js +124 -0
  160. package/src/formulas/statistical.d.ts +135 -0
  161. package/src/formulas/statistical.js +542 -0
  162. package/src/formulas/text-advanced.d.ts +64 -0
  163. package/src/formulas/text-advanced.js +222 -0
  164. package/src/formulas/text-ecma.d.ts +54 -0
  165. package/src/formulas/text-ecma.js +106 -0
  166. package/src/formulas/text-extra.d.ts +216 -0
  167. package/src/formulas/text-extra.js +657 -0
  168. package/src/formulas/text.d.ts +125 -0
  169. package/src/formulas/text.js +628 -0
  170. package/src/global.js +1 -0
  171. package/src/index.d.ts +14 -0
  172. package/src/index.js +14 -0
  173. package/tslint.json +111 -0
@@ -0,0 +1,340 @@
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 { logGamma } from './formula-math-helpers';
18
+ /**
19
+ * Large-sample and array statistical helpers beyond basic descriptive functions.
20
+ *
21
+ * Registers 11 functions including STDEVA, STDEVPA, VARA, VARPA, TRIMMEAN, and others.
22
+ *
23
+ * @hidden
24
+ */
25
+ var StatisticalExtendedFormulas = /** @class */ (function (_super) {
26
+ __extends(StatisticalExtendedFormulas, _super);
27
+ /**
28
+ * @hidden
29
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
30
+ */
31
+ function StatisticalExtendedFormulas(owner) {
32
+ var _this = _super.call(this, owner) || this;
33
+ /** Formula definitions registered with {@link BasicFormulas}. */
34
+ _this.formulas = [
35
+ { formulaName: 'STDEVA', category: 'Statistical', description: 'Estimates standard deviation based on a sample, including text and logicals.' },
36
+ { formulaName: 'STDEVPA', category: 'Statistical', description: 'Calculates standard deviation based on the entire population, including text and logicals.' },
37
+ { formulaName: 'VARA', category: 'Statistical', description: 'Estimates variance based on a sample, including text and logicals.' },
38
+ { formulaName: 'VARPA', category: 'Statistical', description: 'Calculates variance based on the entire population, including text and logicals.' },
39
+ { formulaName: 'TRIMMEAN', category: 'Statistical', description: 'Returns the mean of the interior of a data set.' },
40
+ { formulaName: 'FISHER', category: 'Statistical', description: 'Returns the Fisher transformation.' },
41
+ { formulaName: 'FISHERINV', category: 'Statistical', description: 'Returns the inverse of the Fisher transformation.' },
42
+ { formulaName: 'GAMMALN', category: 'Statistical', description: 'Returns the natural logarithm of the gamma function.' },
43
+ { formulaName: 'SUMX2MY2', category: 'Statistical', description: 'Returns the sum of the difference of squares of corresponding values in two arrays.' },
44
+ { formulaName: 'SUMX2PY2', category: 'Statistical', description: 'Returns the sum of the sum of squares of corresponding values in two arrays.' },
45
+ { formulaName: 'SUMXMY2', category: 'Statistical', description: 'Returns the sum of squares of differences of corresponding values in two arrays.' }
46
+ ];
47
+ return _this;
48
+ }
49
+ StatisticalExtendedFormulas.prototype.stdevVarA = function (args, population, asVar) {
50
+ var errCollection = this.parent.getErrorStrings();
51
+ if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
52
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
53
+ }
54
+ var nums = this.collectSample(args, true);
55
+ if (typeof nums === 'string') {
56
+ return nums;
57
+ }
58
+ if (nums.length < (population ? 1 : 2)) {
59
+ return errCollection[CommonErrors.DivZero];
60
+ }
61
+ var avg = this.mean(nums);
62
+ var sumSq = 0;
63
+ for (var i = 0; i < nums.length; i++) {
64
+ var d = nums[i] - avg;
65
+ sumSq += d * d;
66
+ }
67
+ var denom = population ? nums.length : nums.length - 1;
68
+ var v = sumSq / denom;
69
+ return (asVar ? v : Math.sqrt(v)).toString();
70
+ };
71
+ /**
72
+ * Estimates standard deviation based on a sample, including text and logicals.
73
+ *
74
+ * Excel: `STDEVA(...)`.
75
+ *
76
+ * @hidden
77
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
78
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * engine.computeFormula('=STDEVA(1)');
83
+ * ```
84
+ */
85
+ StatisticalExtendedFormulas.prototype.ComputeSTDEVA = function () {
86
+ var args = [];
87
+ for (var _i = 0; _i < arguments.length; _i++) {
88
+ args[_i] = arguments[_i];
89
+ }
90
+ return this.stdevVarA(args, false, false);
91
+ };
92
+ /**
93
+ * Calculates standard deviation based on the entire population, including text and logicals.
94
+ *
95
+ * Excel: `STDEVPA(...)`.
96
+ *
97
+ * @hidden
98
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
99
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
100
+ */
101
+ StatisticalExtendedFormulas.prototype.ComputeSTDEVPA = function () {
102
+ var args = [];
103
+ for (var _i = 0; _i < arguments.length; _i++) {
104
+ args[_i] = arguments[_i];
105
+ }
106
+ return this.stdevVarA(args, true, false);
107
+ };
108
+ /**
109
+ * Estimates variance based on a sample, including text and logicals.
110
+ *
111
+ * Excel: `VARA(...)`.
112
+ *
113
+ * @hidden
114
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
115
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
116
+ */
117
+ StatisticalExtendedFormulas.prototype.ComputeVARA = function () {
118
+ var args = [];
119
+ for (var _i = 0; _i < arguments.length; _i++) {
120
+ args[_i] = arguments[_i];
121
+ }
122
+ return this.stdevVarA(args, false, true);
123
+ };
124
+ /**
125
+ * Calculates variance based on the entire population, including text and logicals.
126
+ *
127
+ * Excel: `VARPA(...)`.
128
+ *
129
+ * @hidden
130
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
131
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
132
+ */
133
+ StatisticalExtendedFormulas.prototype.ComputeVARPA = function () {
134
+ var args = [];
135
+ for (var _i = 0; _i < arguments.length; _i++) {
136
+ args[_i] = arguments[_i];
137
+ }
138
+ return this.stdevVarA(args, true, true);
139
+ };
140
+ /**
141
+ * Returns the mean of the interior of a data set.
142
+ *
143
+ * Excel: `TRIMMEAN(...)`.
144
+ *
145
+ * @hidden
146
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
147
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
148
+ */
149
+ StatisticalExtendedFormulas.prototype.ComputeTRIMMEAN = function () {
150
+ var args = [];
151
+ for (var _i = 0; _i < arguments.length; _i++) {
152
+ args[_i] = arguments[_i];
153
+ }
154
+ var errCollection = this.parent.getErrorStrings();
155
+ if (isNullOrUndefined(args) || args.length !== 2) {
156
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
157
+ }
158
+ var pct = this.resolveNumberArg(args[1]);
159
+ if (typeof pct === 'string') {
160
+ return pct;
161
+ }
162
+ if (pct < 0 || pct >= 1) {
163
+ return errCollection[CommonErrors.Num];
164
+ }
165
+ var nums = this.collectSample([args[0]], false);
166
+ if (typeof nums === 'string') {
167
+ return nums;
168
+ }
169
+ if (nums.length === 0) {
170
+ return errCollection[CommonErrors.DivZero];
171
+ }
172
+ var sorted = nums.slice().sort(function (a, b) { return a - b; });
173
+ var trim = Math.floor(sorted.length * pct / 2);
174
+ var inner = sorted.slice(trim, sorted.length - trim);
175
+ if (inner.length === 0) {
176
+ return errCollection[CommonErrors.DivZero];
177
+ }
178
+ return this.mean(inner).toString();
179
+ };
180
+ /**
181
+ * Returns the Fisher transformation.
182
+ *
183
+ * Excel: `FISHER(...)`.
184
+ *
185
+ * @hidden
186
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
187
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
188
+ */
189
+ StatisticalExtendedFormulas.prototype.ComputeFISHER = function () {
190
+ var args = [];
191
+ for (var _i = 0; _i < arguments.length; _i++) {
192
+ args[_i] = arguments[_i];
193
+ }
194
+ var errCollection = this.parent.getErrorStrings();
195
+ if (isNullOrUndefined(args) || args.length !== 1) {
196
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
197
+ }
198
+ var x = this.resolveNumberArg(args[0]);
199
+ if (typeof x === 'string') {
200
+ return x;
201
+ }
202
+ if (x <= -1 || x >= 1) {
203
+ return errCollection[CommonErrors.Num];
204
+ }
205
+ return (0.5 * Math.log((1 + x) / (1 - x))).toString();
206
+ };
207
+ /**
208
+ * Returns the inverse of the Fisher transformation.
209
+ *
210
+ * Excel: `FISHERINV(...)`.
211
+ *
212
+ * @hidden
213
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
214
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
215
+ */
216
+ StatisticalExtendedFormulas.prototype.ComputeFISHERINV = function () {
217
+ var args = [];
218
+ for (var _i = 0; _i < arguments.length; _i++) {
219
+ args[_i] = arguments[_i];
220
+ }
221
+ if (isNullOrUndefined(args) || args.length !== 1) {
222
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
223
+ }
224
+ var y = this.resolveNumberArg(args[0]);
225
+ if (typeof y === 'string') {
226
+ return y;
227
+ }
228
+ var e2y = Math.exp(2 * y);
229
+ return ((e2y - 1) / (e2y + 1)).toString();
230
+ };
231
+ /**
232
+ * Returns the natural logarithm of the gamma function.
233
+ *
234
+ * Excel: `GAMMALN(...)`.
235
+ *
236
+ * @hidden
237
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
238
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
239
+ */
240
+ StatisticalExtendedFormulas.prototype.ComputeGAMMALN = function () {
241
+ var args = [];
242
+ for (var _i = 0; _i < arguments.length; _i++) {
243
+ args[_i] = arguments[_i];
244
+ }
245
+ var errCollection = this.parent.getErrorStrings();
246
+ if (isNullOrUndefined(args) || args.length !== 1) {
247
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
248
+ }
249
+ var x = this.resolveNumberArg(args[0]);
250
+ if (typeof x === 'string') {
251
+ return x;
252
+ }
253
+ if (x <= 0) {
254
+ return errCollection[CommonErrors.Num];
255
+ }
256
+ var result = logGamma(x);
257
+ if (!isFinite(result)) {
258
+ return errCollection[CommonErrors.Num];
259
+ }
260
+ return result.toString();
261
+ };
262
+ StatisticalExtendedFormulas.prototype.sumSquaresPair = function (args, mode) {
263
+ var errCollection = this.parent.getErrorStrings();
264
+ if (isNullOrUndefined(args) || args.length !== 2) {
265
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
266
+ }
267
+ var pair = this.collectPair(args);
268
+ if (typeof pair === 'string') {
269
+ return pair;
270
+ }
271
+ var x = pair.x, y = pair.y;
272
+ if (x.length === 0) {
273
+ return errCollection[CommonErrors.DivZero];
274
+ }
275
+ var sum = 0;
276
+ for (var i = 0; i < x.length; i++) {
277
+ if (mode === 'x2my2') {
278
+ sum += x[i] * x[i] - y[i] * y[i];
279
+ }
280
+ else if (mode === 'x2py2') {
281
+ sum += x[i] * x[i] + y[i] * y[i];
282
+ }
283
+ else {
284
+ var d = x[i] - y[i];
285
+ sum += d * d;
286
+ }
287
+ }
288
+ return sum.toString();
289
+ };
290
+ /**
291
+ * Returns the sum of the difference of squares of corresponding values in two arrays.
292
+ *
293
+ * Excel: `SUMX2MY2(...)`.
294
+ *
295
+ * @hidden
296
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
297
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
298
+ */
299
+ StatisticalExtendedFormulas.prototype.ComputeSUMX2MY2 = function () {
300
+ var args = [];
301
+ for (var _i = 0; _i < arguments.length; _i++) {
302
+ args[_i] = arguments[_i];
303
+ }
304
+ return this.sumSquaresPair(args, 'x2my2');
305
+ };
306
+ /**
307
+ * Returns the sum of the sum of squares of corresponding values in two arrays.
308
+ *
309
+ * Excel: `SUMX2PY2(...)`.
310
+ *
311
+ * @hidden
312
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
313
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
314
+ */
315
+ StatisticalExtendedFormulas.prototype.ComputeSUMX2PY2 = function () {
316
+ var args = [];
317
+ for (var _i = 0; _i < arguments.length; _i++) {
318
+ args[_i] = arguments[_i];
319
+ }
320
+ return this.sumSquaresPair(args, 'x2py2');
321
+ };
322
+ /**
323
+ * Returns the sum of squares of differences of corresponding values in two arrays.
324
+ *
325
+ * Excel: `SUMXMY2(...)`.
326
+ *
327
+ * @hidden
328
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
329
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
330
+ */
331
+ StatisticalExtendedFormulas.prototype.ComputeSUMXMY2 = function () {
332
+ var args = [];
333
+ for (var _i = 0; _i < arguments.length; _i++) {
334
+ args[_i] = arguments[_i];
335
+ }
336
+ return this.sumSquaresPair(args, 'xmy2');
337
+ };
338
+ return StatisticalExtendedFormulas;
339
+ }(StatisticalSampleBase));
340
+ export { StatisticalExtendedFormulas };
@@ -0,0 +1,46 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * Conditional statistical aggregates (AVERAGEIFS, SUMIFS) over multi-criteria ranges.
6
+ *
7
+ * Registered functions: MAXIFS, MINIFS.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class StatisticalIfsFormulas 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
+ /**
20
+ * Returns the maximum value among cells specified by criteria.
21
+ *
22
+ * Excel: `MAXIFS(...)`.
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('=MAXIFS(1)');
31
+ * ```
32
+ */
33
+ ComputeMAXIFS(...args: string[]): string | number;
34
+ /**
35
+ * Returns the minimum value among cells specified by criteria.
36
+ *
37
+ * Excel: `MINIFS(...)`.
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
+ ComputeMINIFS(...args: string[]): string | number;
44
+ private aggregateIfs;
45
+ private matchesCriteria;
46
+ }
@@ -0,0 +1,180 @@
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
+ * Conditional statistical aggregates (AVERAGEIFS, SUMIFS) over multi-criteria ranges.
19
+ *
20
+ * Registered functions: MAXIFS, MINIFS.
21
+ *
22
+ * @hidden
23
+ */
24
+ var StatisticalIfsFormulas = /** @class */ (function (_super) {
25
+ __extends(StatisticalIfsFormulas, _super);
26
+ /**
27
+ * @hidden
28
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
29
+ */
30
+ function StatisticalIfsFormulas(owner) {
31
+ var _this = _super.call(this, owner) || this;
32
+ /** Formula definitions registered with {@link BasicFormulas}. */
33
+ _this.formulas = [
34
+ { formulaName: 'MAXIFS', category: 'Statistical', description: 'Returns the maximum value among cells specified by criteria.' },
35
+ { formulaName: 'MINIFS', category: 'Statistical', description: 'Returns the minimum value among cells specified by criteria.' }
36
+ ];
37
+ return _this;
38
+ }
39
+ /**
40
+ * Returns the maximum value among cells specified by criteria.
41
+ *
42
+ * Excel: `MAXIFS(...)`.
43
+ *
44
+ * @hidden
45
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
46
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * engine.computeFormula('=MAXIFS(1)');
51
+ * ```
52
+ */
53
+ StatisticalIfsFormulas.prototype.ComputeMAXIFS = function () {
54
+ var args = [];
55
+ for (var _i = 0; _i < arguments.length; _i++) {
56
+ args[_i] = arguments[_i];
57
+ }
58
+ return this.aggregateIfs(args, true);
59
+ };
60
+ /**
61
+ * Returns the minimum value among cells specified by criteria.
62
+ *
63
+ * Excel: `MINIFS(...)`.
64
+ *
65
+ * @hidden
66
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
67
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
68
+ */
69
+ StatisticalIfsFormulas.prototype.ComputeMINIFS = function () {
70
+ var args = [];
71
+ for (var _i = 0; _i < arguments.length; _i++) {
72
+ args[_i] = arguments[_i];
73
+ }
74
+ return this.aggregateIfs(args, false);
75
+ };
76
+ StatisticalIfsFormulas.prototype.aggregateIfs = function (args, isMax) {
77
+ var errCollection = this.parent.getErrorStrings();
78
+ if (isNullOrUndefined(args) || args.length < 3 || args.length % 2 === 0) {
79
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
80
+ }
81
+ var valueRange = args[0];
82
+ var valueCells = this.parent.getCellCollection(valueRange);
83
+ var values = Array.isArray(valueCells) ? valueCells : [valueCells];
84
+ var criteriaPairs = [];
85
+ for (var i = 1; i < args.length; i += 2) {
86
+ criteriaPairs.push([args[i], args[i + 1]]);
87
+ }
88
+ var criteriaCellsList = [];
89
+ for (var p = 0; p < criteriaPairs.length; p++) {
90
+ var cells = this.parent.getCellCollection(criteriaPairs[p][0]);
91
+ var list = Array.isArray(cells) ? cells : [cells];
92
+ if (list.length !== values.length) {
93
+ return errCollection[CommonErrors.Value];
94
+ }
95
+ criteriaCellsList.push(list);
96
+ }
97
+ var result = null;
98
+ var matched = false;
99
+ for (var i = 0; i < values.length; i++) {
100
+ var ok = true;
101
+ for (var p = 0; p < criteriaPairs.length; p++) {
102
+ var cellVal = this.parent.getValueFromArg(criteriaCellsList[p][i]);
103
+ if (!this.matchesCriteria(cellVal, criteriaPairs[p][1])) {
104
+ ok = false;
105
+ break;
106
+ }
107
+ }
108
+ if (!ok) {
109
+ continue;
110
+ }
111
+ var valStr = this.parent.getValueFromArg(values[i]);
112
+ if (errCollection.indexOf(valStr) > -1) {
113
+ return valStr;
114
+ }
115
+ if (valStr === '' || !this.parent.isNumber(valStr)) {
116
+ continue;
117
+ }
118
+ var num = this.parent.parseFloat(valStr);
119
+ matched = true;
120
+ if (result === null) {
121
+ result = num;
122
+ }
123
+ else if (isMax ? num > result : num < result) {
124
+ result = num;
125
+ }
126
+ }
127
+ if (!matched || result === null) {
128
+ return '0';
129
+ }
130
+ return result.toString();
131
+ };
132
+ StatisticalIfsFormulas.prototype.matchesCriteria = function (cellVal, criteriaArg) {
133
+ var criteria = criteriaArg.trim();
134
+ var isStringVal = criteria.startsWith(this.parent.tic) && criteria.endsWith(this.parent.tic);
135
+ if (isStringVal) {
136
+ criteria = this.parent.removeTics(criteria);
137
+ }
138
+ else if (this.parent.isCellReference(criteria)) {
139
+ criteria = this.parent.getValueFromArg(criteria);
140
+ }
141
+ else {
142
+ criteria = this.parent.getValueFromArg(criteria);
143
+ if (!this.parent.isCellReference(criteriaArg)) {
144
+ criteria = this.parent.removeTics(criteria);
145
+ }
146
+ }
147
+ var op = 'equal';
148
+ if (criteria.startsWith('<=')) {
149
+ op = 'lessEq';
150
+ criteria = criteria.substring(2);
151
+ }
152
+ else if (criteria.startsWith('>=')) {
153
+ op = 'greaterEq';
154
+ criteria = criteria.substring(2);
155
+ }
156
+ else if (criteria.startsWith('<>')) {
157
+ op = 'notEq';
158
+ criteria = criteria.substring(2);
159
+ }
160
+ else if (criteria.startsWith('<')) {
161
+ op = 'less';
162
+ criteria = criteria.substring(1);
163
+ }
164
+ else if (criteria.startsWith('>')) {
165
+ op = 'greater';
166
+ criteria = criteria.substring(1);
167
+ }
168
+ else if (criteria.startsWith('=')) {
169
+ op = 'equal';
170
+ criteria = criteria.substring(1);
171
+ }
172
+ criteria = criteria.trim();
173
+ if (criteria.startsWith(this.parent.tic)) {
174
+ criteria = this.parent.removeTics(criteria);
175
+ }
176
+ return this.parent.processLogical([cellVal.toLowerCase(), criteria.toLowerCase()], op) === this.parent.trueValue;
177
+ };
178
+ return StatisticalIfsFormulas;
179
+ }(FormulaModuleBase));
180
+ export { StatisticalIfsFormulas };
@@ -0,0 +1,84 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { StatisticalSampleBase } from './statistical-sample-base';
4
+ /**
5
+ * Distribution shape metrics: skewness, kurtosis, and moment-based descriptive statistics.
6
+ *
7
+ * Registered functions: AVEDEV, DEVSQ, HARMEAN, SKEW, KURT, STANDARDIZE.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class StatisticalMomentsFormulas 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 average of the absolute deviations of data points from their mean.
21
+ *
22
+ * Excel: `AVEDEV(...)`.
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('=AVEDEV(1)');
31
+ * ```
32
+ */
33
+ ComputeAVEDEV(...args: string[]): string | number;
34
+ /**
35
+ * Returns the sum of squares of deviations.
36
+ *
37
+ * Excel: `DEVSQ(...)`.
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
+ ComputeDEVSQ(...args: string[]): string | number;
44
+ /**
45
+ * Returns the harmonic mean.
46
+ *
47
+ * Excel: `HARMEAN(...)`.
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
+ ComputeHARMEAN(...args: string[]): string | number;
54
+ /**
55
+ * Returns the skewness of a distribution.
56
+ *
57
+ * Excel: `SKEW(...)`.
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
+ ComputeSKEW(...args: string[]): string | number;
64
+ /**
65
+ * Returns the kurtosis of a data set.
66
+ *
67
+ * Excel: `KURT(...)`.
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
+ ComputeKURT(...args: string[]): string | number;
74
+ /**
75
+ * Returns a normalized value from a distribution.
76
+ *
77
+ * Excel: `STANDARDIZE(...)`.
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
+ ComputeSTANDARDIZE(...args: string[]): string | number;
84
+ }