Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(formula): add some statistical formulas (#3463)

wpxp1234560a7658aebe92
diff --git a/packages/engine-formula/src/basics/__tests__/date.spec.ts b/packages/engine-formula/src/basics/__tests__/date.spec.ts
index f376a7b2a9..5c580b6ed4 100644
--- a/packages/engine-formula/src/basics/__tests__/date.spec.ts
+++ b/packages/engine-formula/src/basics/__tests__/date.spec.ts
@@ -15,8 +15,8 @@
*/
import { describe, expect, it } from 'vitest';
-import { excelDateSerial, excelDateTimeSerial, excelSerialToDate, formatDateDefault, isValidDateStr } from '../date';
import { stripErrorMargin } from '../../engine/utils/math-kit';
+import { excelDateSerial, excelDateTimeSerial, excelSerialToDate, formatDateDefault, isValidDateStr } from '../date';
describe('Test date', () => {
it('Function excelDateSerial', () => {
diff --git a/packages/engine-formula/src/basics/__tests__/engineering.spec.ts b/packages/engine-formula/src/basics/__tests__/engineering.spec.ts
index 2fcb1dfeef..0ae2936c5d 100644
--- a/packages/engine-formula/src/basics/__tests__/engineering.spec.ts
+++ b/packages/engine-formula/src/basics/__tests__/engineering.spec.ts
@@ -15,8 +15,8 @@
*/
import { describe, expect, it } from 'vitest';
-import { BESSEL } from '../engineering';
import { Complex } from '../complex';
+import { BESSEL } from '../engineering';
describe('Test ref regex', () => {
it('BESSEL.besselj test', () => {
diff --git a/packages/engine-formula/src/basics/engineering.ts b/packages/engine-formula/src/basics/engineering.ts
index 20c6ef836e..abf82babc0 100644
--- a/packages/engine-formula/src/basics/engineering.ts
+++ b/packages/engine-formula/src/basics/engineering.ts
@@ -436,3 +436,30 @@ export function erf(x: number): number {
return isNeg ? res - 1 : 1 - res;
};
+
+export function erfc(x: number): number {
+ return 1 - erf(x);
+}
+
+export function erfcINV(p: number): number {
+ if (p >= 2) {
+ return -100;
+ }
+
+ if (p <= 0) {
+ return 100;
+ }
+
+ const _p = (p < 1) ? p : 2 - p;
+ const temp = Math.sqrt(-2 * Math.log(_p / 2));
+
+ let x = -0.70711 * ((2.30753 + temp * 0.27061) / (1 + temp * (0.99229 + temp * 0.04481)) - temp);
+
+ for (let j = 0; j < 2; j++) {
+ const err = erfc(x) - _p;
+
+ x += err / (1.12837916709551257 * Math.exp(-x * x) - x * err); // eslint-disable-line
+ }
+
+ return (p < 1) ? x : -x;
+};
diff --git a/packages/engine-formula/src/basics/statistical.ts b/packages/engine-formula/src/basics/statistical.ts
new file mode 100644
index 0000000000..d30bfa973c
--- /dev/null
+++ b/packages/engine-formula/src/basics/statistical.ts
@@ -0,0 +1,642 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { isRealNum } from '@univerjs/core';
+import { erf, erfcINV } from './engineering';
+import { calculateCombin } from './math';
+import type { ArrayValueObject } from '../engine/value-object/array-value-object';
+import type { BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
+
+export function betaCDF(x: number, alpha: number, beta: number): number {
+ if (x <= 0) {
+ return 0;
+ }
+
+ if (x >= 1) {
+ return 1;
+ }
+
+ return incompleteBetaFunction(x, alpha, beta);
+}
+
+export function betaPDF(x: number, alpha: number, beta: number): number {
+ if (x <= 0 || x >= 1) {
+ return 0;
+ }
+
+ if (alpha === 1 && beta === 1) {
+ return 1;
+ }
+
+ if (alpha < 512 && beta < 512) {
+ return ((x ** (alpha - 1)) * ((1 - x) ** (beta - 1))) / betaFunction(alpha, beta);
+ }
+
+ return Math.exp((alpha - 1) * Math.log(x) + (beta - 1) * Math.log(1 - x) - betaFunctionNaturalLogarithm(alpha, beta));
+}
+
+export function betaINV(probability: number, alpha: number, beta: number): number {
+ if (probability <= 0) {
+ return 0;
+ }
+
+ if (probability >= 1) {
+ return 1;
+ }
+
+ const EPSILON = 1e-8;
+ let x;
+
+ if (alpha >= 1 && beta >= 1) {
+ const p = (probability < 0.5) ? probability : 1 - probability;
+ const temp = Math.sqrt(-2 * Math.log(p));
+
+ x = (2.30753 + temp * 0.27061) / (1 + temp * (0.99229 + temp * 0.04481)) - temp;
+
+ if (probability < 0.5) {
+ x = -x;
+ }
+
+ const temp1 = (x * x - 3) / 6;
+ const temp2 = 2 / (1 / (2 * alpha - 1) + 1 / (2 * beta - 1));
+ const temp3 = (x * Math.sqrt(temp1 + temp2) / temp2) - (1 / (2 * beta - 1) - 1 / (2 * alpha - 1)) * (temp1 + 5 / 6 - 2 / (3 * temp2));
+
+ x = alpha / (alpha + beta * Math.exp(2 * temp3));
+ } else {
+ const temp1 = Math.exp(alpha * Math.log(alpha / (alpha + beta))) / alpha;
+ const temp2 = Math.exp(beta * Math.log(beta / (alpha + beta))) / beta;
+ const temp3 = temp1 + temp2;
+
+ if (probability < temp1 / temp3) {
+ x = (alpha * temp3 * probability) ** (1 / alpha);
+ } else {
+ x = 1 - (beta * temp3 * (1 - probability)) ** (1 / beta);
+ }
+ }
+
+ const betalnNeg = -betaFunctionNaturalLogarithm(alpha, beta);
+ let ibeta, t, u;
+
+ for (let j = 0; j < 10; j++) {
+ if (x === 0 || x === 1) {
+ return x;
+ }
+
+ ibeta = incompleteBetaFunction(x, alpha, beta) - probability;
+
+ t = Math.exp((alpha - 1) * Math.log(x) + (beta - 1) * Math.log(1 - x) + betalnNeg);
+ u = ibeta / t;
+ x -= (t = u / (1 - 0.5 * Math.min(1, u * ((alpha - 1) / x - (beta - 1) / (1 - x)))));
+
+ if (x <= 0) {
+ x = 0.5 * (x + t);
+ }
+
+ if (x >= 1) {
+ x = 0.5 * (x + t + 1);
+ }
+
+ if (Math.abs(t) < EPSILON * x && j > 0) {
+ break;
+ }
+ }
+
+ return x;
+}
+
+function incompleteBetaFunction(x: number, alpha: number, beta: number): number {
+ const bt = (x === 0 || x === 1)
+ ? 0
+ : Math.exp(logGamma(alpha + beta) - logGamma(alpha) - logGamma(beta) + alpha * Math.log(x) + beta * Math.log(1 - x));
+
+ if (x < (alpha + 1) / (alpha + beta + 2)) {
+ return bt * betaContinuedFraction(x, alpha, beta) / alpha;
+ }
+
+ return 1 - bt * betaContinuedFraction(1 - x, beta, alpha) / beta;
+}
+
+function betaContinuedFraction(x: number, alpha: number, beta: number): number {
+ const MAX_ITER = 100;
+ const EPSILON = 1e-8;
+
+ let d = 1 - (alpha + beta) * x / (alpha + 1);
+
+ if (Math.abs(d) < EPSILON) {
+ d = EPSILON;
+ }
+
+ d = 1 / d;
+
+ let c = 1;
+ let h = d;
+
+ for (let m = 1; m <= MAX_ITER; m++) {
+ let temp = m * (beta - m) * x / ((alpha - 1 + m * 2) * (alpha + m * 2));
+
+ d = 1 + temp * d;
+
+ if (Math.abs(d) < EPSILON) {
+ d = EPSILON;
+ }
+
+ c = 1 + temp / c;
+
+ if (Math.abs(c) < EPSILON) {
+ c = EPSILON;
+ }
+
+ d = 1 / d;
+ h *= d * c;
+
+ temp = -(alpha + m) * (alpha + beta + m) * x / ((alpha + m * 2) * (alpha + 1 + m * 2));
+
+ d = 1 + temp * d;
+
+ if (Math.abs(d) < EPSILON) {
+ d = EPSILON;
+ }
+
+ c = 1 + temp / c;
+
+ if (Math.abs(c) < EPSILON) {
+ c = EPSILON;
+ }
+
+ d = 1 / d;
+ h *= d * c;
+
+ if (Math.abs(d * c - 1) < EPSILON) {
+ break;
+ }
+ }
+
+ return h;
+}
+
+function betaFunction(alpha: number, beta: number): number {
+ if (alpha + beta > 170) {
+ return Math.exp(betaFunctionNaturalLogarithm(alpha, beta));
+ }
+
+ return gammaFunction(alpha) * gammaFunction(beta) / gammaFunction(alpha + beta);
+}
+
+function betaFunctionNaturalLogarithm(alpha: number, beta: number): number {
+ return logGamma(alpha) + logGamma(beta) - logGamma(alpha + beta);
+}
+
+function logGamma(x: number): number {
+ const coefficients = [
+ 76.18009172947146, -86.50532032941677, 24.01409824083091, // eslint-disable-line
+ -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5,
+ ];
+
+ let y = x;
+ let tmp = x + 5.5;
+ tmp -= (x + 0.5) * Math.log(tmp);
+ let ser = 1.000000000190015;
+
+ for (let j = 0; j < 6; j++) {
+ y += 1;
+ ser += coefficients[j] / y;
+ }
+
+ return -tmp + Math.log(2.5066282746310005 * ser / x); // eslint-disable-line
+}
+
+function gammaFunction(x: number): number {
+ const p = [
+ -1.716185138865495, 24.76565080557592, -379.80425647094563,
+ 629.3311553128184, 866.9662027904133, -31451.272968848367,
+ -36144.413418691176, 66456.14382024054,
+ ];
+ const q = [
+ -30.8402300119739, 315.35062697960416, -1015.1563674902192,
+ -3107.771671572311, 22538.118420980151, 4755.8462775278811, // eslint-disable-line
+ -134659.9598649693, -115132.2596755535,
+ ];
+
+ let fact = 0;
+ let y = x;
+
+ if (x > 171.6243769536076) {
+ return Infinity;
+ }
+
+ if (y <= 0) {
+ const resMod = y % 1 + 3.6e-16;
+
+ if (resMod) {
+ fact = (!(y & 1) ? 1 : -1) * Math.PI / Math.sin(Math.PI * resMod);
+ y = 1 - y;
+ } else {
+ return Infinity;
+ }
+ }
+
+ const yi = y;
+ let n = 0;
+ let z;
+
+ if (y < 1) {
+ z = y++;
+ } else {
+ z = (y -= n = (y | 0) - 1) - 1;
+ }
+
+ let xnum = 0;
+ let xden = 0;
+
+ for (let i = 0; i < 8; ++i) {
+ xnum = (xnum + p[i]) * z;
+ xden = xden * z + q[i];
+ }
+
+ let res = xnum / xden + 1;
+
+ if (yi < y) {
+ res /= yi;
+ } else if (yi > y) {
+ for (let i = 0; i < n; ++i) {
+ res *= y;
+ y++;
+ }
+ }
+
+ if (fact) {
+ res = fact / res;
+ }
+
+ return res;
+}
+
+export function binomialCDF(x: number, trials: number, probability: number): number {
+ if (x < 0) {
+ return 0;
+ }
+
+ if (x >= trials) {
+ return 1;
+ }
+
+ if (probability < 0 || probability > 1 || trials <= 0) {
+ return Number.NaN;
+ }
+
+ let result = 0;
+
+ for (let i = 0; i <= x; i++) {
+ result += binomialPDF(i, trials, probability);
+ }
+
+ return result;
+}
+
+export function binomialPDF(x: number, trials: number, probability: number): number {
+ if (probability === 0 || probability === 1) {
+ if (trials * probability === x) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ return calculateCombin(trials, x) * (probability ** x) * ((1 - probability) ** (trials - x));
+}
+
+export function chisquareCDF(x: number, degFreedom: number): number {
+ if (x <= 0) {
+ return 0;
+ }
+
+ return lowRegGamma(degFreedom / 2, x / 2);
+}
+
+export function chisquarePDF(x: number, degFreedom: number): number {
+ if (x < 0) {
+ return 0;
+ }
+
+ if (x === 0 && degFreedom === 2) {
+ return 0.5;
+ }
+
+ return Math.exp((degFreedom / 2 - 1) * Math.log(x) - x / 2 - (degFreedom / 2) * Math.log(2) - logGamma(degFreedom / 2));
+}
+
+export function chisquareINV(probability: number, degFreedom: number): number {
+ if (probability <= 0) {
+ return 0;
+ }
+
+ if (probability >= 1) {
+ return Infinity;
+ }
+
+ return 2 * lowRegGammaInverse(probability, degFreedom / 2);
+}
+
+function lowRegGamma(a: number, x: number): number {
+ if (x < 0 || a <= 0) {
+ return Number.NaN;
+ }
+
+ // calculate maximum number of itterations required for a
+ const MAX_ITER = Math.min(-~(Math.log((a >= 1) ? a : 1 / a) * 8.5 + a * 0.4 + 17), 10000);
+ const aln = logGamma(a);
+ const exp = Math.exp(-x + a * Math.log(x) - aln);
+
+ let _a = a;
+ let sum = 1 / a;
+ let del = sum;
+
+ if (x < a + 1) {
+ if (exp === 0) {
+ return 0;
+ }
+
+ for (let i = 1; i <= MAX_ITER; i++) {
+ sum += del *= x / ++_a;
+ }
+
+ return sum * exp;
+ }
+
+ if (exp === 0) {
+ return 1;
+ }
+
+ let b = x + 1 - a;
+ let c = 1 / 1.0e-30;
+ let d = 1 / b;
+ let h = d;
+
+ for (let i = 1; i <= MAX_ITER; i++) {
+ const temp = -i * (i - a);
+
+ b += 2;
+ d = temp * d + b;
+ c = b + temp / c;
+ d = 1 / d;
+ h *= d * c;
+ }
+
+ return 1 - h * exp;
+};
+
+function lowRegGammaInverse(p: number, a: number): number {
+ if (p <= 0) {
+ return 0;
+ }
+
+ if (p >= 1) {
+ return Math.max(100, a + 100 * Math.sqrt(a));
+ }
+
+ let x;
+
+ if (a > 1) {
+ const _p = (p < 0.5) ? p : 1 - p;
+ const temp = Math.sqrt(-2 * Math.log(_p));
+
+ x = (2.30753 + temp * 0.27061) / (1 + temp * (0.99229 + temp * 0.04481)) - temp;
+
+ if (p < 0.5) {
+ x = -x;
+ }
+
+ x = Math.max(1e-3, a * ((1 - 1 / (9 * a) - x / (3 * Math.sqrt(a))) ** 3));
+ } else {
+ const temp = 1 - a * (0.253 + a * 0.12);
+
+ if (p < temp) {
+ x = (p / temp) ** (1 / a);
+ } else {
+ x = 1 - Math.log(1 - (p - temp) / (1 - temp));
+ }
+ }
+
+ const EPSILON = 1e-8;
+ const aln = logGamma(a);
+
+ let err, t;
+
+ for (let j = 0; j < 12; j++) {
+ if (x <= 0) {
+ return 0;
+ }
+
+ err = lowRegGamma(a, x) - p;
+
+ if (a > 1) {
+ t = Math.exp((a - 1) * (Math.log(a - 1) - 1) - aln) * Math.exp(-(x - (a - 1)) + (a - 1) * (Math.log(x) - Math.log(a - 1)));
+ } else {
+ t = Math.exp(-x + (a - 1) * Math.log(x) - aln);
+ }
+
+ if (t !== 0) {
+ t = (err / t) / (1 - 0.5 * Math.min(1, (err / t) * ((a - 1) / x - 1)));
+ }
+
+ x -= t;
+
+ if (x <= 0) {
+ x = 0.5 * (x + t);
+ }
+
+ if (Math.abs(t) < EPSILON * x) {
+ break;
+ }
+ }
+
+ return x;
+}
+
+export function studentTINV(probability: number, degFreedom: number): number {
+ let x = betaINV(2 * Math.min(probability, 1 - probability), 0.5 * degFreedom, 0.5);
+ x = Math.sqrt(degFreedom * (1 - x) / x);
+
+ return (probability > 0.5) ? x : -x;
+}
+
+export function exponentialCDF(x: number, lambda: number): number {
+ if (x < 0) {
+ return 0;
+ }
+
+ return 1 - Math.exp(-lambda * x);
+}
+
+export function exponentialPDF(x: number, lambda: number): number {
+ if (x < 0) {
+ return 0;
+ }
+
+ return lambda * Math.exp(-lambda * x);
+}
+
+export function centralFCDF(x: number, degFreedom1: number, degFreedom2: number): number {
+ if (x < 0) {
+ return 0;
+ }
+
+ return incompleteBetaFunction((degFreedom1 * x) / (degFreedom1 * x + degFreedom2), degFreedom1 / 2, degFreedom2 / 2);
+}
+
+export function centralFPDF(x: number, degFreedom1: number, degFreedom2: number): number {
+ if (x < 0) {
+ return 0;
+ }
+
+ if (x === 0 && degFreedom1 < 2) {
+ return Infinity;
+ }
+
+ if (x === 0 && degFreedom1 === 2) {
+ return 1;
+ }
+
+ let result = 1 / betaFunction(degFreedom1 / 2, degFreedom2 / 2);
+ result *= (degFreedom1 / degFreedom2) ** (degFreedom1 / 2);
+ result *= x ** ((degFreedom1 / 2) - 1);
+ result *= (1 + (degFreedom1 / degFreedom2) * x) ** (-(degFreedom1 + degFreedom2) / 2);
+
+ return result;
+}
+
+export function centralFINV(probability: number, degFreedom1: number, degFreedom2: number): number {
+ if (probability <= 0) {
+ return 0;
+ }
+
+ if (probability >= 1) {
+ return Infinity;
+ }
+
+ return degFreedom2 / (degFreedom1 * (1 / betaINV(probability, degFreedom1 / 2, degFreedom2 / 2) - 1));
+}
+
+export function forecastLinear(x: number, knownYs: number[], knownXs: number[]): number {
+ const n = knownYs.length;
+
+ let knownYsSum = 0;
+ let knownXsSum = 0;
+
+ for (let i = 0; i < n; i++) {
+ knownYsSum += knownYs[i];
+ knownXsSum += knownXs[i];
+ }
+
+ const knownYsMean = knownYsSum / n;
+ const knownXsMean = knownXsSum / n;
+
+ let num = 0;
+ let den = 0;
+
+ for (let i = 0; i < n; i++) {
+ num += (knownYs[i] - knownYsMean) * (knownXs[i] - knownXsMean);
+ den += (knownXs[i] - knownXsMean) ** 2;
+ }
+
+ if (den === 0) {
+ return Infinity;
+ }
+
+ const b = num / den;
+ const a = knownYsMean - b * knownXsMean;
+
+ return a + b * x;
+}
+
+export function normalCDF(x: number, mean: number, standardDev: number): number {
+ return 0.5 * (1 + erf((x - mean) / Math.sqrt(2 * standardDev * standardDev)));
+}
+
+export function normalPDF(x: number, mean: number, standardDev: number): number {
+ return Math.exp(-0.5 * Math.log(2 * Math.PI) - Math.log(standardDev) - (x - mean) ** 2 / (2 * standardDev * standardDev));
+}
+
+export function normalINV(probability: number, mean: number, standardDev: number): number {
+ // eslint-disable-next-line
+ return -1.41421356237309505 * standardDev * erfcINV(2 * probability) + mean;
+}
+
+export function getTwoArrayNumberValues(
+ array1: BaseValueObject,
+ array2: BaseValueObject,
+ count: number,
+ array1ColumnCount: number,
+ array2ColumnCount: number
+) {
+ const array1Values: number[] = [];
+ const array2Values: number[] = [];
+ let noCalculate = true;
+
+ for (let i = 0; i < count; i++) {
+ const array1RowIndex = Math.floor(i / array1ColumnCount);
+ const array1ColumnIndex = i % array1ColumnCount;
+
+ const array2RowIndex = Math.floor(i / array2ColumnCount);
+ const array2ColumnIndex = i % array2ColumnCount;
+
+ const array1Object = array1.isArray() ? (array1 as ArrayValueObject).get(array1RowIndex, array1ColumnIndex) as BaseValueObject : array1;
+ const array2Object = array2.isArray() ? (array2 as ArrayValueObject).get(array2RowIndex, array2ColumnIndex) as BaseValueObject : array2;
+
+ if (array1Object.isError()) {
+ return {
+ isError: true,
+ errorObject: array1Object as ErrorValueObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ };
+ }
+
+ if (array2Object.isError()) {
+ return {
+ isError: true,
+ errorObject: array2Object as ErrorValueObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ };
+ }
+
+ if (array1Object.isNull() || array2Object.isNull() || array1Object.isBoolean() || array2Object.isBoolean()) {
+ continue;
+ }
+
+ const array1Value = array1Object.getValue();
+ const array2Value = array2Object.getValue();
+
+ if (!isRealNum(array1Value) || !isRealNum(array2Value)) {
+ continue;
+ }
+
+ array1Values.push(+array1Value);
+ array2Values.push(+array2Value);
+ noCalculate = false;
+ }
+
+ return {
+ isError: false,
+ errorObject: null,
+ array1Values,
+ array2Values,
+ noCalculate,
+ };
+}
diff --git a/packages/engine-formula/src/engine/value-object/lambda-value-object.ts b/packages/engine-formula/src/engine/value-object/lambda-value-object.ts
index 0ef8ca30ba..4e772aabd0 100644
--- a/packages/engine-formula/src/engine/value-object/lambda-value-object.ts
+++ b/packages/engine-formula/src/engine/value-object/lambda-value-object.ts
@@ -23,7 +23,7 @@ import { BaseValueObject, ErrorValueObject } from './base-value-object';
import type { BaseAstNode } from '../ast-node/base-ast-node';
import type { LambdaParameterNode } from '../ast-node/lambda-parameter-node';
import type { Interpreter } from '../interpreter/interpreter';
-import type { BaseReferenceObject } from '../reference-object/base-reference-object';
+import type { BaseReferenceObject, FunctionVariantType } from '../reference-object/base-reference-object';
function getRootLexerHasValueNode(node: Nullable<BaseAstNode>): Nullable<BaseAstNode> {
if (!node) {
@@ -55,7 +55,7 @@ export class LambdaValueObjectObject extends BaseValueObject {
return new LambdaValueObjectObject(lambdaNode, interpreter, lambdaPrivacyVarKeys);
}
- private _lambdaPrivacyValueMap = new Map<string, BaseValueObject>();
+ private _lambdaPrivacyValueMap = new Map<string, FunctionVariantType>();
constructor(
private _lambdaNode: BaseAstNode,
@@ -72,7 +72,7 @@ export class LambdaValueObjectObject extends BaseValueObject {
return true;
}
- execute(...variants: BaseValueObject[]) {
+ execute(...variants: FunctionVariantType[]) {
const paramCount = this._lambdaPrivacyVarKeys.length;
if (variants.length !== paramCount) {
return ErrorValueObject.create(ErrorType.VALUE);
@@ -127,7 +127,7 @@ export class LambdaValueObjectObject extends BaseValueObject {
}
}
- private _setLambdaPrivacyValueMap(variants: BaseValueObject[]) {
+ private _setLambdaPrivacyValueMap(variants: FunctionVariantType[]) {
for (let i = 0; i < variants.length; i++) {
const variant = variants[i];
const key = this._lambdaPrivacyVarKeys[i];
diff --git a/packages/engine-formula/src/functions/compatibility/betadist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/compatibility/betadist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..6b096f9ae2
--- /dev/null
+++ b/packages/engine-formula/src/functions/compatibility/betadist/__tests__/index.spec.ts
@@ -0,0 +1,151 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_COMPATIBILITY } from '../../function-names';
+import { Betadist } from '../index';
+
+describe('Test betadist function', () => {
+ const testFunction = new Betadist(FUNCTION_NAMES_COMPATIBILITY.BETADIST);
+
+ describe('Betadist', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(0.6854705810117458);
+ });
+
+ it('Alpha and beta value test', () => {
+ const x = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(0);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const alpha2 = NumberValueObject.create(8);
+ const beta2 = NumberValueObject.create(0);
+ const result2 = testFunction.calculate(x, alpha2, beta2, A, B);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+
+ const alpha3 = NumberValueObject.create(1);
+ const beta3 = NumberValueObject.create(1);
+ const result3 = testFunction.calculate(x, alpha3, beta3, A, B);
+ expect(getObjectValue(result3)).toBe(0.5000000000000002);
+ });
+
+ it('X and A and B value test', () => {
+ const x = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const x2 = NumberValueObject.create(1);
+ const A2 = NumberValueObject.create(1);
+ const B2 = NumberValueObject.create(3);
+ const result2 = testFunction.calculate(x2, alpha, beta, A2, B2);
+ expect(getObjectValue(result2)).toBe(0);
+
+ const x3 = NumberValueObject.create(3);
+ const result3 = testFunction.calculate(x3, alpha, beta, A2, B2);
+ expect(getObjectValue(result3)).toBe(1);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const x2 = NumberValueObject.create(2);
+ const A2 = NullValueObject.create();
+ const B2 = NullValueObject.create();
+ const result2 = testFunction.calculate(x2, alpha, beta, A2, B2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, A, B);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0, ErrorType.VALUE, 0.00028348362316367936, 0, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, 0.9745907595394001, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/compatibility/betadist/index.ts b/packages/engine-formula/src/functions/compatibility/betadist/index.ts
new file mode 100644
index 0000000000..04ec0c214e
--- /dev/null
+++ b/packages/engine-formula/src/functions/compatibility/betadist/index.ts
@@ -0,0 +1,116 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { betaCDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+
+export class Betadist extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 5;
+
+ override calculate(
+ x: BaseValueObject,
+ alpha: BaseValueObject,
+ beta: BaseValueObject,
+ A?: BaseValueObject,
+ B?: BaseValueObject
+ ): BaseValueObject {
+ let _A = A ?? NumberValueObject.create(0);
+ let _B = B ?? NumberValueObject.create(1);
+
+ if (_A.isNull()) {
+ _A = NumberValueObject.create(0);
+ }
+
+ if (_B.isNull()) {
+ _B = NumberValueObject.create(1);
+ }
+
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getRowCount() : 1,
+ beta.isArray() ? (beta as ArrayValueObject).getRowCount() : 1,
+ _A.isArray() ? (_A as ArrayValueObject).getRowCount() : 1,
+ _B.isArray() ? (_B as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getColumnCount() : 1,
+ beta.isArray() ? (beta as ArrayValueObject).getColumnCount() : 1,
+ _A.isArray() ? (_A as ArrayValueObject).getColumnCount() : 1,
+ _B.isArray() ? (_B as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType.NA));
+ const betaArray = expandArrayValueObject(maxRowLength, maxColumnLength, beta, ErrorValueObject.create(ErrorType.NA));
+ const AArray = expandArrayValueObject(maxRowLength, maxColumnLength, _A, ErrorValueObject.create(ErrorType.NA));
+ const BArray = expandArrayValueObject(maxRowLength, maxColumnLength, _B, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const alphaObject = alphaArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const betaObject = betaArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const AObject = AArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const BObject = BArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, alphaObject, betaObject, AObject, BObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ alphaObject: BaseValueObject,
+ betaObject: BaseValueObject,
+ AObject: BaseValueObject,
+ BObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, alphaObject, betaObject, AObject, BObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _alphaObject, _betaObject, _AObject, _BObject] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const alphaValue = +_alphaObject.getValue();
+ const betaValue = +_betaObject.getValue();
+ const AValue = +_AObject.getValue();
+ const BValue = +_BObject.getValue();
+
+ if (alphaValue <= 0 || betaValue <= 0 || xValue < AValue || xValue > BValue || AValue === BValue) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = betaCDF((xValue - AValue) / (BValue - AValue), alphaValue, betaValue); ;
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/compatibility/function-map.ts b/packages/engine-formula/src/functions/compatibility/function-map.ts
index ea4e9557dd..675dceb72d 100644
--- a/packages/engine-formula/src/functions/compatibility/function-map.ts
+++ b/packages/engine-formula/src/functions/compatibility/function-map.ts
@@ -14,14 +14,48 @@
* limitations under the License.
*/
+import { BetaInv } from '../statistical/beta-inv';
+import { BinomDist } from '../statistical/binom-dist';
+import { BinomInv } from '../statistical/binom-inv';
+import { ChisqDistRt } from '../statistical/chisq-dist-rt';
+import { ChisqInvRt } from '../statistical/chisq-inv-rt';
+import { ChisqTest } from '../statistical/chisq-test';
+import { ConfidenceNorm } from '../statistical/confidence-norm';
+import { CovarianceP } from '../statistical/covariance-p';
+import { ExponDist } from '../statistical/expon-dist';
+import { FDistRt } from '../statistical/f-dist-rt';
+import { FInvRt } from '../statistical/f-inv-rt';
+import { FTest } from '../statistical/f-test';
+import { NormDist } from '../statistical/norm-dist';
+import { NormInv } from '../statistical/norm-inv';
+import { NormSInv } from '../statistical/norm-s-inv';
import { StdevP } from '../statistical/stdev-p';
import { StdevS } from '../statistical/stdev-s';
import { VarP } from '../statistical/var-p';
import { VarS } from '../statistical/var-s';
-import { Rank } from './rank';
+import { Betadist } from './betadist';
import { FUNCTION_NAMES_COMPATIBILITY } from './function-names';
+import { Normsdist } from './normsdist';
+import { Rank } from './rank';
export const functionCompatibility = [
+ [Betadist, FUNCTION_NAMES_COMPATIBILITY.BETADIST],
+ [BetaInv, FUNCTION_NAMES_COMPATIBILITY.BETAINV],
+ [BinomDist, FUNCTION_NAMES_COMPATIBILITY.BINOMDIST],
+ [ChisqDistRt, FUNCTION_NAMES_COMPATIBILITY.CHIDIST],
+ [ChisqInvRt, FUNCTION_NAMES_COMPATIBILITY.CHIINV],
+ [ChisqTest, FUNCTION_NAMES_COMPATIBILITY.CHITEST],
+ [ConfidenceNorm, FUNCTION_NAMES_COMPATIBILITY.CONFIDENCE],
+ [CovarianceP, FUNCTION_NAMES_COMPATIBILITY.COVAR],
+ [BinomInv, FUNCTION_NAMES_COMPATIBILITY.CRITBINOM],
+ [ExponDist, FUNCTION_NAMES_COMPATIBILITY.EXPONDIST],
+ [FDistRt, FUNCTION_NAMES_COMPATIBILITY.FDIST],
+ [FInvRt, FUNCTION_NAMES_COMPATIBILITY.FINV],
+ [FTest, FUNCTION_NAMES_COMPATIBILITY.FTEST],
+ [NormDist, FUNCTION_NAMES_COMPATIBILITY.NORMDIST],
+ [NormInv, FUNCTION_NAMES_COMPATIBILITY.NORMINV],
+ [Normsdist, FUNCTION_NAMES_COMPATIBILITY.NORMSDIST],
+ [NormSInv, FUNCTION_NAMES_COMPATIBILITY.NORMSINV],
[Rank, FUNCTION_NAMES_COMPATIBILITY.RANK],
[StdevS, FUNCTION_NAMES_COMPATIBILITY.STDEV],
[StdevP, FUNCTION_NAMES_COMPATIBILITY.STDEVP],
diff --git a/packages/engine-formula/src/functions/compatibility/normsdist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/compatibility/normsdist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..42a3c5b3f0
--- /dev/null
+++ b/packages/engine-formula/src/functions/compatibility/normsdist/__tests__/index.spec.ts
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_COMPATIBILITY } from '../../function-names';
+import { Normsdist } from '../index';
+
+describe('Test normsdist function', () => {
+ const testFunction = new Normsdist(FUNCTION_NAMES_COMPATIBILITY.NORMSDIST);
+
+ describe('Normsdist', () => {
+ it('Value is normal', () => {
+ const z = NumberValueObject.create(1.2069);
+ const result = testFunction.calculate(z);
+ expect(getObjectValue(result)).toBe(0.8862646711511419);
+ });
+
+ it('Value is normal string', () => {
+ const z = StringValueObject.create('test');
+ const result = testFunction.calculate(z);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const z = BooleanValueObject.create(true);
+ const result = testFunction.calculate(z);
+ expect(getObjectValue(result)).toBe(0.8413447460685429);
+ });
+
+ it('Value is null', () => {
+ const z = NullValueObject.create();
+ const result = testFunction.calculate(z);
+ expect(getObjectValue(result)).toBe(0.5);
+ });
+
+ it('Value is error', () => {
+ const z = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(z);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const z = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(z);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.8413447460685429, ErrorType.VALUE, 0.8906514475743081, 0.8413447460685429, 0.5, 0.5],
+ [0.5, 1, 0.9903581300546417, ErrorType.VALUE, 0.0013498980316301035, ErrorType.NAME],
+ ]);
+
+ const z2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(z2);
+ expect(getObjectValue(result2)).toStrictEqual(0.8413447460685429);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/compatibility/normsdist/index.ts b/packages/engine-formula/src/functions/compatibility/normsdist/index.ts
new file mode 100644
index 0000000000..3aa3f84739
--- /dev/null
+++ b/packages/engine-formula/src/functions/compatibility/normsdist/index.ts
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { normalCDF } from '../../../basics/statistical';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Normsdist extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(z: BaseValueObject): BaseValueObject {
+ if (z.isArray()) {
+ const resultArray = (z as ArrayValueObject).mapValue((zObject) => this._handleSignleObject(zObject));
+
+ if ((z as ArrayValueObject).getRowCount() === 1 && (z as ArrayValueObject).getColumnCount() === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ return this._handleSignleObject(z);
+ }
+
+ private _handleSignleObject(zObject: BaseValueObject): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(zObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_zObject] = variants as BaseValueObject[];
+
+ const zValue = +_zObject.getValue();
+
+ const result = normalCDF(zValue, 0, 1);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/engineering/erfc-precise/__tests__/index.spec.ts b/packages/engine-formula/src/functions/engineering/erfc-precise/__tests__/index.spec.ts
index f660ecfe78..76e2562985 100644
--- a/packages/engine-formula/src/functions/engineering/erfc-precise/__tests__/index.spec.ts
+++ b/packages/engine-formula/src/functions/engineering/erfc-precise/__tests__/index.spec.ts
@@ -16,12 +16,12 @@
import { describe, expect, it } from 'vitest';
-import { FUNCTION_NAMES_ENGINEERING } from '../../function-names';
-import { ErfcPrecise } from '../index';
-import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
-import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { FUNCTION_NAMES_ENGINEERING } from '../../function-names';
+import { ErfcPrecise } from '../index';
describe('Test erfc.precise function', () => {
const testFunction = new ErfcPrecise(FUNCTION_NAMES_ENGINEERING.ERFC_PRECISE);
diff --git a/packages/engine-formula/src/functions/engineering/erfc-precise/index.ts b/packages/engine-formula/src/functions/engineering/erfc-precise/index.ts
index cedeb52d41..977d3209c7 100644
--- a/packages/engine-formula/src/functions/engineering/erfc-precise/index.ts
+++ b/packages/engine-formula/src/functions/engineering/erfc-precise/index.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import { erfc } from '../../../basics/engineering';
import { ErrorType } from '../../../basics/error-type';
+import { checkVariantsErrorIsArrayOrBoolean } from '../../../engine/utils/check-variant-error';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
-import { BaseFunction } from '../../base-function';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
-import { erf } from '../../../basics/engineering';
-import { checkVariantsErrorIsArrayOrBoolean } from '../../../engine/utils/check-variant-error';
+import { BaseFunction } from '../../base-function';
export class ErfcPrecise extends BaseFunction {
override minParams = 1;
@@ -41,7 +41,7 @@ export class ErfcPrecise extends BaseFunction {
return ErrorValueObject.create(ErrorType.VALUE);
}
- const result = 1 - erf(xValue);
+ const result = erfc(xValue);
return NumberValueObject.create(result);
}
diff --git a/packages/engine-formula/src/functions/engineering/erfc/__tests__/index.spec.ts b/packages/engine-formula/src/functions/engineering/erfc/__tests__/index.spec.ts
index 547b790d45..0675ae1762 100644
--- a/packages/engine-formula/src/functions/engineering/erfc/__tests__/index.spec.ts
+++ b/packages/engine-formula/src/functions/engineering/erfc/__tests__/index.spec.ts
@@ -16,12 +16,12 @@
import { describe, expect, it } from 'vitest';
-import { FUNCTION_NAMES_ENGINEERING } from '../../function-names';
-import { Erfc } from '../index';
-import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
-import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { FUNCTION_NAMES_ENGINEERING } from '../../function-names';
+import { Erfc } from '../index';
describe('Test erfc function', () => {
const testFunction = new Erfc(FUNCTION_NAMES_ENGINEERING.ERFC);
diff --git a/packages/engine-formula/src/functions/engineering/erfc/index.ts b/packages/engine-formula/src/functions/engineering/erfc/index.ts
index 3d62de97fd..80ddfa3252 100644
--- a/packages/engine-formula/src/functions/engineering/erfc/index.ts
+++ b/packages/engine-formula/src/functions/engineering/erfc/index.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import { erfc } from '../../../basics/engineering';
import { ErrorType } from '../../../basics/error-type';
+import { checkVariantsErrorIsArrayOrBoolean } from '../../../engine/utils/check-variant-error';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
-import { BaseFunction } from '../../base-function';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
-import { erf } from '../../../basics/engineering';
-import { checkVariantsErrorIsArrayOrBoolean } from '../../../engine/utils/check-variant-error';
+import { BaseFunction } from '../../base-function';
export class Erfc extends BaseFunction {
override minParams = 1;
@@ -41,7 +41,7 @@ export class Erfc extends BaseFunction {
return ErrorValueObject.create(ErrorType.VALUE);
}
- const result = 1 - erf(xValue);
+ const result = erfc(xValue);
return NumberValueObject.create(result);
}
diff --git a/packages/engine-formula/src/functions/logical/bycol/index.ts b/packages/engine-formula/src/functions/logical/bycol/index.ts
index a94967001c..a684c680e7 100644
--- a/packages/engine-formula/src/functions/logical/bycol/index.ts
+++ b/packages/engine-formula/src/functions/logical/bycol/index.ts
@@ -14,12 +14,14 @@
* limitations under the License.
*/
+import type { IRange, Nullable } from '@univerjs/core';
import { ErrorType } from '../../../basics/error-type';
import { expandArrayValueObject } from '../../../engine/utils/array-object';
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
import type { LambdaValueObjectObject } from '../../../engine/value-object/lambda-value-object';
export class Bycol extends BaseFunction {
@@ -27,9 +29,20 @@ export class Bycol extends BaseFunction {
override maxParams = 2;
- override calculate(array: BaseValueObject, lambda: BaseValueObject): BaseValueObject {
- if (array.isError()) {
- return array;
+ override needsReferenceObject = true;
+
+ // eslint-disable-next-line
+ override calculate(array: FunctionVariantType, lambda: BaseValueObject): BaseValueObject {
+ let _array = array;
+ let _array_reference: Nullable<BaseReferenceObject> = null;
+
+ if (array.isReferenceObject()) {
+ _array = (array as BaseReferenceObject).toArrayValueObject();
+ _array_reference = array as BaseReferenceObject;
+ }
+
+ if (_array.isError()) {
+ return _array as ErrorValueObject;
}
if (lambda.isError()) {
@@ -44,7 +57,7 @@ export class Bycol extends BaseFunction {
const rowCount = array.isArray() ? (array as ArrayValueObject).getRowCount() : 1;
const columnCount = array.isArray() ? (array as ArrayValueObject).getColumnCount() : 1;
- const _array = expandArrayValueObject(rowCount, columnCount, array);
+ _array = expandArrayValueObject(rowCount, columnCount, _array as BaseValueObject);
const result: BaseValueObject[][] = [[]];
@@ -56,7 +69,7 @@ export class Bycol extends BaseFunction {
rows.push([col]);
}
- const lambdaVariant = ArrayValueObject.create({
+ let lambdaVariant: FunctionVariantType = ArrayValueObject.create({
calculateValueList: rows,
rowCount,
columnCount: 1,
@@ -66,6 +79,18 @@ export class Bycol extends BaseFunction {
column: 0,
});
+ if (_array_reference) {
+ const { startRow, startColumn } = _array_reference.getRangePosition();
+ const range: IRange = {
+ startRow,
+ startColumn: startColumn + c,
+ endRow: startRow + rowCount - 1,
+ endColumn: startColumn + c,
+ };
+
+ lambdaVariant = this.createReferenceObject(_array_reference, range);
+ }
+
let value = _lambda.execute(lambdaVariant) as BaseValueObject;
if (value.isArray()) {
diff --git a/packages/engine-formula/src/functions/logical/byrow/index.ts b/packages/engine-formula/src/functions/logical/byrow/index.ts
index ec28395fff..6d3190ae2b 100644
--- a/packages/engine-formula/src/functions/logical/byrow/index.ts
+++ b/packages/engine-formula/src/functions/logical/byrow/index.ts
@@ -14,12 +14,14 @@
* limitations under the License.
*/
+import type { IRange, Nullable } from '@univerjs/core';
import { ErrorType } from '../../../basics/error-type';
import { expandArrayValueObject } from '../../../engine/utils/array-object';
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
import type { LambdaValueObjectObject } from '../../../engine/value-object/lambda-value-object';
export class Byrow extends BaseFunction {
@@ -27,9 +29,20 @@ export class Byrow extends BaseFunction {
override maxParams = 2;
- override calculate(array: BaseValueObject, lambda: BaseValueObject): BaseValueObject {
- if (array.isError()) {
- return array;
+ override needsReferenceObject = true;
+
+ // eslint-disable-next-line
+ override calculate(array: FunctionVariantType, lambda: BaseValueObject): BaseValueObject {
+ let _array = array;
+ let _array_reference: Nullable<BaseReferenceObject> = null;
+
+ if (array.isReferenceObject()) {
+ _array = (array as BaseReferenceObject).toArrayValueObject();
+ _array_reference = array as BaseReferenceObject;
+ }
+
+ if (_array.isError()) {
+ return _array as ErrorValueObject;
}
if (lambda.isError()) {
@@ -44,7 +57,7 @@ export class Byrow extends BaseFunction {
const rowCount = array.isArray() ? (array as ArrayValueObject).getRowCount() : 1;
const columnCount = array.isArray() ? (array as ArrayValueObject).getColumnCount() : 1;
- const _array = expandArrayValueObject(rowCount, columnCount, array);
+ _array = expandArrayValueObject(rowCount, columnCount, _array as BaseValueObject);
const result: BaseValueObject[][] = [];
@@ -56,7 +69,7 @@ export class Byrow extends BaseFunction {
rows[0].push(col);
}
- const lambdaVariant = ArrayValueObject.create({
+ let lambdaVariant: FunctionVariantType = ArrayValueObject.create({
calculateValueList: rows,
rowCount: 1,
columnCount,
@@ -66,6 +79,18 @@ export class Byrow extends BaseFunction {
column: 0,
});
+ if (_array_reference) {
+ const { startRow, startColumn } = _array_reference.getRangePosition();
+ const range: IRange = {
+ startRow: startRow + r,
+ startColumn,
+ endRow: startRow + r,
+ endColumn: startColumn + columnCount - 1,
+ };
+
+ lambdaVariant = this.createReferenceObject(_array_reference, range);
+ }
+
let value = _lambda.execute(lambdaVariant) as BaseValueObject;
if (value.isArray()) {
diff --git a/packages/engine-formula/src/functions/logical/map/index.ts b/packages/engine-formula/src/functions/logical/map/index.ts
index 50d05473ea..2ca24da4b6 100644
--- a/packages/engine-formula/src/functions/logical/map/index.ts
+++ b/packages/engine-formula/src/functions/logical/map/index.ts
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-import type { Nullable } from '@univerjs/core';
+import type { IRange, Nullable } from '@univerjs/core';
import { ErrorType } from '../../../basics/error-type';
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
import type { LambdaValueObjectObject } from '../../../engine/value-object/lambda-value-object';
export class Map extends BaseFunction {
@@ -27,8 +28,8 @@ export class Map extends BaseFunction {
override maxParams = 255;
- override calculate(...variants: BaseValueObject[]): BaseValueObject {
- const _variants: BaseValueObject[] = [];
+ override calculate(...variants: FunctionVariantType[]): BaseValueObject {
+ const _variants: FunctionVariantType[] = [];
let lambda: Nullable<LambdaValueObjectObject> = null;
let maxRowLength = 0;
let maxColumnLength = 0;
@@ -36,8 +37,14 @@ export class Map extends BaseFunction {
for (let i = 0; i < variants.length; i++) {
const variant = variants[i];
- if (variant.isError()) {
- return variant;
+ let _variant = variant;
+
+ if (_variant.isReferenceObject()) {
+ _variant = (variant as BaseReferenceObject).toArrayValueObject();
+ }
+
+ if (_variant.isError()) {
+ return _variant as ErrorValueObject;
}
if (i === variants.length - 1) {
@@ -49,13 +56,17 @@ export class Map extends BaseFunction {
} else {
_variants.push(variant);
- maxRowLength = Math.max(maxRowLength, variant.isArray() ? (variant as ArrayValueObject).getRowCount() : 1);
- maxColumnLength = Math.max(maxColumnLength, variant.isArray() ? (variant as ArrayValueObject).getColumnCount() : 1);
+ maxRowLength = Math.max(maxRowLength, _variant.isArray() ? (_variant as ArrayValueObject).getRowCount() : 1);
+ maxColumnLength = Math.max(maxColumnLength, _variant.isArray() ? (_variant as ArrayValueObject).getColumnCount() : 1);
}
}
const resultArray = this._getResultArray(_variants, lambda as LambdaValueObjectObject, maxRowLength, maxColumnLength);
+ if (resultArray instanceof ErrorValueObject) {
+ return resultArray;
+ }
+
if (maxRowLength === 1 && maxColumnLength === 1) {
return resultArray[0][0];
}
@@ -71,22 +82,29 @@ export class Map extends BaseFunction {
});
}
- private _getResultArray(variants: BaseValueObject[], lambda: LambdaValueObjectObject, maxRowLength: number, maxColumnLength: number): BaseValueObject[][] {
+ // eslint-disable-next-line
+ private _getResultArray(variants: FunctionVariantType[], lambda: LambdaValueObjectObject, maxRowLength: number, maxColumnLength: number): BaseValueObject[][] | ErrorValueObject {
const resultArray: BaseValueObject[][] = [];
for (let r = 0; r < maxRowLength; r++) {
const row: BaseValueObject[] = [];
for (let c = 0; c < maxColumnLength; c++) {
- const lambdaVariant = [];
+ const lambdaVariant: FunctionVariantType[] = [];
let isRowPushed = false;
for (let i = 0; i < variants.length; i++) {
- const variant = variants[i];
+ let variant = variants[i];
+ let _variant_reference: Nullable<BaseReferenceObject> = null;
+
+ if (variant.isReferenceObject()) {
+ _variant_reference = variant as BaseReferenceObject;
+ variant = (variant as BaseReferenceObject).toArrayValueObject();
+ }
if (!variant.isArray()) {
if (r === 0 && c === 0) {
- lambdaVariant.push(variant);
+ lambdaVariant.push(_variant_reference || variant);
continue;
} else {
row.push(ErrorValueObject.create(ErrorType.NA));
@@ -95,7 +113,7 @@ export class Map extends BaseFunction {
}
}
- const valueObject = (variant as ArrayValueObject).get(r, c);
+ let valueObject: Nullable<FunctionVariantType> = (variant as ArrayValueObject).get(r, c);
if (!valueObject) {
row.push(ErrorValueObject.create(ErrorType.NA));
@@ -103,6 +121,18 @@ export class Map extends BaseFunction {
break;
}
+ if (_variant_reference) {
+ const { startRow, startColumn } = _variant_reference.getRangePosition();
+ const range: IRange = {
+ startRow: startRow + r,
+ startColumn: startColumn + c,
+ endRow: startRow + r,
+ endColumn: startColumn + c,
+ };
+
+ valueObject = this.createReferenceObject(_variant_reference, range);
+ }
+
lambdaVariant.push(valueObject);
}
@@ -113,6 +143,13 @@ export class Map extends BaseFunction {
let value = (lambda as LambdaValueObjectObject).execute(...lambdaVariant) as BaseValueObject;
if (value.isArray()) {
+ const rowCount = (value as ArrayValueObject).getRowCount();
+ const columnCount = (value as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return ErrorValueObject.create(ErrorType.CALC);
+ }
+
value = (value as ArrayValueObject).get(0, 0) as BaseValueObject;
}
diff --git a/packages/engine-formula/src/functions/logical/reduce/index.ts b/packages/engine-formula/src/functions/logical/reduce/index.ts
index 777f38ad97..1213b93711 100644
--- a/packages/engine-formula/src/functions/logical/reduce/index.ts
+++ b/packages/engine-formula/src/functions/logical/reduce/index.ts
@@ -14,10 +14,12 @@
* limitations under the License.
*/
+import type { IRange, Nullable } from '@univerjs/core';
import { ErrorType } from '../../../basics/error-type';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
import type { LambdaValueObjectObject } from '../../../engine/value-object/lambda-value-object';
@@ -26,15 +28,43 @@ export class Reduce extends BaseFunction {
override maxParams = 3;
- override calculate(initialValue: BaseValueObject, array: BaseValueObject, lambda: BaseValueObject): BaseValueObject {
- if (initialValue.isArray()) {
- return initialValue.mapValue((initialValueObject) => this._handleSingleValueObject(initialValueObject, array, lambda));
+ override needsReferenceObject = true;
+
+ override calculate(initialValue: FunctionVariantType, array: FunctionVariantType, lambda: BaseValueObject): BaseValueObject {
+ let _initialValue = initialValue;
+ let _initialValue_reference: Nullable<BaseReferenceObject> = null;
+
+ if (initialValue.isReferenceObject()) {
+ _initialValue = (initialValue as BaseReferenceObject).toArrayValueObject();
+ _initialValue_reference = initialValue as BaseReferenceObject;
+ }
+
+ _initialValue = _initialValue as BaseValueObject;
+
+ let _array = array;
+ let _array_reference: Nullable<BaseReferenceObject> = null;
+
+ if (array.isReferenceObject()) {
+ _array = (array as BaseReferenceObject).toArrayValueObject();
+ _array_reference = array as BaseReferenceObject;
+ }
+
+ _array = _array as BaseValueObject;
+
+ if (_initialValue.isArray()) {
+ return _initialValue.mapValue((initialValueObject) => this._handleSingleValueObject(initialValueObject, _array, lambda, _initialValue_reference, _array_reference));
}
- return this._handleSingleValueObject(initialValue, array, lambda);
+ return this._handleSingleValueObject(_initialValue, _array, lambda, _initialValue_reference, _array_reference);
}
- private _handleSingleValueObject(initialValue: BaseValueObject, array: BaseValueObject, lambda: BaseValueObject): BaseValueObject {
+ private _handleSingleValueObject(
+ initialValue: BaseValueObject,
+ array: BaseValueObject,
+ lambda: BaseValueObject,
+ _initialValue_reference: Nullable<BaseReferenceObject>,
+ _array_reference: Nullable<BaseReferenceObject>
+ ): BaseValueObject {
if (initialValue.isError()) {
return initialValue;
}
@@ -56,22 +86,34 @@ export class Reduce extends BaseFunction {
const rowCount = array.isArray() ? (array as ArrayValueObject).getRowCount() : 1;
const columnCount = array.isArray() ? (array as ArrayValueObject).getColumnCount() : 1;
- let accumulator = initialValue;
+ let accumulator: FunctionVariantType = initialValue;
+
+ if (_initialValue_reference) {
+ accumulator = _initialValue_reference;
+ }
for (let r = 0; r < rowCount; r++) {
for (let c = 0; c < columnCount; c++) {
- const valueObject = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
+ let valueObject: FunctionVariantType = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
if (valueObject.isError()) {
return valueObject;
}
- let value = _lambda.execute(accumulator, valueObject) as BaseValueObject;
+ if (_array_reference) {
+ const { startRow, startColumn } = _array_reference.getRangePosition();
+ const range: IRange = {
+ startRow: startRow + r,
+ startColumn: startColumn + c,
+ endRow: startRow + r,
+ endColumn: startColumn + c,
+ };
- if (value.isArray()) {
- value = (value as ArrayValueObject).get(0, 0) as BaseValueObject;
+ valueObject = this.createReferenceObject(_array_reference, range);
}
+ let value = _lambda.execute(accumulator, valueObject) as BaseValueObject;
+
if (value.isError()) {
return value;
}
@@ -84,12 +126,10 @@ export class Reduce extends BaseFunction {
}
}
- const result = +accumulator.getValue();
-
- if (Number.isNaN(result) || !Number.isFinite(result)) {
- return ErrorValueObject.create(ErrorType.VALUE);
+ if (accumulator.isReferenceObject()) {
+ return (accumulator as BaseReferenceObject).toArrayValueObject();
}
- return NumberValueObject.create(result);
+ return accumulator as BaseValueObject;
}
}
diff --git a/packages/engine-formula/src/functions/logical/scan/index.ts b/packages/engine-formula/src/functions/logical/scan/index.ts
index 9b366ff56b..54c805192e 100644
--- a/packages/engine-formula/src/functions/logical/scan/index.ts
+++ b/packages/engine-formula/src/functions/logical/scan/index.ts
@@ -14,11 +14,13 @@
* limitations under the License.
*/
+import type { IRange, Nullable } from '@univerjs/core';
import { ErrorType } from '../../../basics/error-type';
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
import type { LambdaValueObjectObject } from '../../../engine/value-object/lambda-value-object';
export class Scan extends BaseFunction {
@@ -26,13 +28,35 @@ export class Scan extends BaseFunction {
override maxParams = 3;
- override calculate(initialValue: BaseValueObject, array: BaseValueObject, lambda: BaseValueObject): BaseValueObject {
- if (initialValue.isError()) {
- return initialValue;
+ override needsReferenceObject = true;
+
+ override calculate(initialValue: FunctionVariantType, array: FunctionVariantType, lambda: BaseValueObject): BaseValueObject {
+ let _initialValue = initialValue;
+ let _initialValue_reference: Nullable<BaseReferenceObject> = null;
+
+ if (initialValue.isReferenceObject()) {
+ _initialValue = (initialValue as BaseReferenceObject).toArrayValueObject();
+ _initialValue_reference = initialValue as BaseReferenceObject;
}
- if (array.isError()) {
- return array;
+ _initialValue = _initialValue as BaseValueObject;
+
+ let _array = array;
+ let _array_reference: Nullable<BaseReferenceObject> = null;
+
+ if (array.isReferenceObject()) {
+ _array = (array as BaseReferenceObject).toArrayValueObject();
+ _array_reference = array as BaseReferenceObject;
+ }
+
+ _array = _array as BaseValueObject;
+
+ if (_initialValue.isError()) {
+ return _initialValue;
+ }
+
+ if (_array.isError()) {
+ return _array;
}
if (lambda.isError()) {
@@ -43,39 +67,49 @@ export class Scan extends BaseFunction {
return ErrorValueObject.create(ErrorType.VALUE);
}
- let _initialValue = initialValue;
-
- if (initialValue.isArray()) {
- const rowCount = (initialValue as ArrayValueObject).getRowCount();
- const columnCount = (initialValue as ArrayValueObject).getColumnCount();
+ if (_initialValue.isArray()) {
+ const rowCount = (_initialValue as ArrayValueObject).getRowCount();
+ const columnCount = (_initialValue as ArrayValueObject).getColumnCount();
if (rowCount > 1 || columnCount > 1) {
return ErrorValueObject.create(ErrorType.CALC);
}
- _initialValue = (initialValue as ArrayValueObject).get(0, 0) as BaseValueObject;
+ _initialValue = (_initialValue as ArrayValueObject).get(0, 0) as BaseValueObject;
}
- return this._getResult(_initialValue, array, lambda as LambdaValueObjectObject);
+ return this._getResult(_initialValue, _array, lambda as LambdaValueObjectObject, _initialValue_reference, _array_reference);
}
- private _getResult(initialValue: BaseValueObject, array: BaseValueObject, lambda: LambdaValueObjectObject): BaseValueObject {
+ // eslint-disable-next-line
+ private _getResult(
+ initialValue: BaseValueObject,
+ array: BaseValueObject,
+ lambda: LambdaValueObjectObject,
+ _initialValue_reference: Nullable<BaseReferenceObject>,
+ _array_reference: Nullable<BaseReferenceObject>
+ ): BaseValueObject {
+ const resultArray: BaseValueObject[][] = [];
const rowCount = array.isArray() ? (array as ArrayValueObject).getRowCount() : 1;
const columnCount = array.isArray() ? (array as ArrayValueObject).getColumnCount() : 1;
- let accumulator = initialValue;
- const resultArray: BaseValueObject[][] = [];
+ // let accumulator = initialValue;
+ let accumulator: FunctionVariantType = initialValue;
+
+ if (_initialValue_reference) {
+ accumulator = _initialValue_reference;
+ }
for (let r = 0; r < rowCount; r++) {
const row: BaseValueObject[] = [];
for (let c = 0; c < columnCount; c++) {
if (accumulator.isError()) {
- row.push(accumulator);
+ row.push(accumulator as BaseValueObject);
continue;
}
- const valueObject = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
+ let valueObject: FunctionVariantType = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
if (valueObject.isError()) {
accumulator = valueObject;
@@ -83,9 +117,28 @@ export class Scan extends BaseFunction {
continue;
}
+ if (_array_reference) {
+ const { startRow, startColumn } = _array_reference.getRangePosition();
+ const range: IRange = {
+ startRow: startRow + r,
+ startColumn: startColumn + c,
+ endRow: startRow + r,
+ endColumn: startColumn + c,
+ };
+
+ valueObject = this.createReferenceObject(_array_reference, range);
+ }
+
let value = lambda.execute(accumulator, valueObject) as BaseValueObject;
if (value.isArray()) {
+ const rowCount = (value as ArrayValueObject).getRowCount();
+ const columnCount = (value as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return ErrorValueObject.create(ErrorType.CALC);
+ }
+
value = (value as ArrayValueObject).get(0, 0) as BaseValueObject;
}
diff --git a/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.ts b/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.ts
index 0a7b8c6b94..13c2dd9595 100644
--- a/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.ts
+++ b/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.ts
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-import type { Injector, IWorkbookData } from '@univerjs/core';
+import { CellValueType, LocaleType } from '@univerjs/core';
import { beforeEach, describe, expect, it } from 'vitest';
-import { CellValueType, LocaleType } from '@univerjs/core';
+import type { Injector, IWorkbookData } from '@univerjs/core';
+import { ErrorType } from '../../../../basics/error-type';
import { Lexer } from '../../../../engine/analysis/lexer';
-import type { LexerNode } from '../../../../engine/analysis/lexer-node';
import { AstTreeBuilder } from '../../../../engine/analysis/parser';
-import type { BaseAstNode } from '../../../../engine/ast-node/base-ast-node';
import { Interpreter } from '../../../../engine/interpreter/interpreter';
import { IFormulaCurrentConfigService } from '../../../../services/current-data.service';
import { IFunctionService } from '../../../../services/function.service';
@@ -29,7 +28,8 @@ import { IFormulaRuntimeService } from '../../../../services/runtime.service';
import { createFunctionTestBed, getObjectValue } from '../../../__tests__/create-function-test-bed';
import { FUNCTION_NAMES_LOOKUP } from '../../function-names';
import { Offset } from '../index';
-import { ErrorType } from '../../../../basics/error-type';
+import type { LexerNode } from '../../../../engine/analysis/lexer-node';
+import type { BaseAstNode } from '../../../../engine/ast-node/base-ast-node';
const getTestWorkbookData = (): IWorkbookData => {
return {
diff --git a/packages/engine-formula/src/functions/lookup/offset/index.ts b/packages/engine-formula/src/functions/lookup/offset/index.ts
index 1aa0dbf9ab..f9aa43e263 100644
--- a/packages/engine-formula/src/functions/lookup/offset/index.ts
+++ b/packages/engine-formula/src/functions/lookup/offset/index.ts
@@ -15,13 +15,13 @@
*/
import { ErrorType } from '../../../basics/error-type';
-import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
import { expandArrayValueObject } from '../../../engine/utils/array-object';
-import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
-import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
import { ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
export class Offset extends BaseFunction {
override minParams = 3;
@@ -81,24 +81,26 @@ export class Offset extends BaseFunction {
_columns = (_columns as BaseReferenceObject).toArrayValueObject();
}
- let _height = height;
+ let _height = height ?? NumberValueObject.create(rowCount);
- // The default row height is the row height of reference.
- if (!_height) {
- _height = NumberValueObject.create(rowCount);
- } else if (_height.isReferenceObject()) {
+ if (_height.isReferenceObject()) {
_height = (_height as BaseReferenceObject).toArrayValueObject();
}
- let _width = width;
+ if ((_height as BaseValueObject).isNull()) {
+ _height = NumberValueObject.create(rowCount);
+ }
- // The default column width is the column width of reference.
- if (!_width) {
- _width = NumberValueObject.create(columnCount);
- } else if (_width.isReferenceObject()) {
+ let _width = width ?? NumberValueObject.create(columnCount);
+
+ if (_width.isReferenceObject()) {
_width = (_width as BaseReferenceObject).toArrayValueObject();
}
+ if ((_width as BaseValueObject).isNull()) {
+ _width = NumberValueObject.create(columnCount);
+ }
+
// If rows/columns/height/width is a range, it needs to be extended
// get max row length
const maxRowLength = Math.max(
@@ -123,6 +125,11 @@ export class Offset extends BaseFunction {
// If any parameter of row/columns/height/width is an array(not single cell reference), an error will be reported, and the error report also needs to be expanded and specific error information is required. Otherwise, calculate the offset.
if (maxRowLength === 1 && maxColumnLength === 1) {
+ _rows = _rows.isArray() ? (_rows as ArrayValueObject).get(0, 0) as BaseValueObject : _rows;
+ _columns = _columns.isArray() ? (_columns as ArrayValueObject).get(0, 0) as BaseValueObject : _columns;
+ _height = _height.isArray() ? (_height as ArrayValueObject).get(0, 0) as BaseValueObject : _height;
+ _width = _width.isArray() ? (_width as ArrayValueObject).get(0, 0) as BaseValueObject : _width;
+
return this._handleSingleObject(reference as BaseReferenceObject, _rows, _columns, _height, _width);
}
@@ -157,11 +164,32 @@ export class Offset extends BaseFunction {
});
}
+ // eslint-disable-next-line
private _handleSingleObject(reference: BaseReferenceObject, rowsValue: BaseValueObject, columnsValue: BaseValueObject, heightValue: BaseValueObject, widthValue: BaseValueObject, isReportError = false) {
const { startRow: referenceStartRow, startColumn: referenceStartColumn } = reference.getRangePosition();
- const rowOffset = this.getIndexNumValue(rowsValue);
- const columnOffset = this.getIndexNumValue(columnsValue);
+ let _rowsValue = rowsValue;
+
+ if (_rowsValue.isString()) {
+ _rowsValue = _rowsValue.convertToNumberObjectValue();
+ }
+
+ if (_rowsValue.isError()) {
+ return _rowsValue;
+ }
+
+ let _columnsValue = columnsValue;
+
+ if (_columnsValue.isString()) {
+ _columnsValue = _columnsValue.convertToNumberObjectValue();
+ }
+
+ if (_columnsValue.isError()) {
+ return _columnsValue;
+ }
+
+ const rowOffset = +_rowsValue.getValue();
+ const columnOffset = +_columnsValue.getValue();
if (typeof rowOffset !== 'number' || typeof columnOffset !== 'number') {
return ErrorValueObject.create(ErrorType.VALUE);
diff --git a/packages/engine-formula/src/functions/statistical/beta-dist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/beta-dist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..d7e4a689d8
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/beta-dist/__tests__/index.spec.ts
@@ -0,0 +1,197 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { BetaDist } from '../index';
+
+describe('Test betaDist function', () => {
+ const testFunction = new BetaDist(FUNCTION_NAMES_STATISTICAL.BETA_DIST);
+
+ describe('BetaDist', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(0.6854705810117458);
+
+ const result2 = testFunction.calculate(x, alpha, beta, cumulative);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Alpha and beta value test', () => {
+ const x = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(0);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const alpha2 = NumberValueObject.create(8);
+ const beta2 = NumberValueObject.create(0);
+ const result2 = testFunction.calculate(x, alpha2, beta2, cumulative, A, B);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+
+ const alpha3 = NumberValueObject.create(1);
+ const beta3 = NumberValueObject.create(1);
+ const result3 = testFunction.calculate(x, alpha3, beta3, cumulative, A, B);
+ expect(getObjectValue(result3)).toBe(0.5000000000000002);
+ });
+
+ it('X and A and B value test', () => {
+ const x = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const x2 = NumberValueObject.create(1);
+ const A2 = NumberValueObject.create(1);
+ const B2 = NumberValueObject.create(3);
+ const result2 = testFunction.calculate(x2, alpha, beta, cumulative, A2, B2);
+ expect(getObjectValue(result2)).toBe(0);
+
+ const x3 = NumberValueObject.create(3);
+ const result3 = testFunction.calculate(x3, alpha, beta, cumulative, A2, B2);
+ expect(getObjectValue(result3)).toBe(1);
+ });
+
+ it('Cumulative value is normal', () => {
+ const x = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(false);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(1.4837646484375002);
+
+ const alpha2 = NumberValueObject.create(1);
+ const beta2 = NumberValueObject.create(1);
+ const result2 = testFunction.calculate(x, alpha2, beta2, cumulative, A, B);
+ expect(getObjectValue(result2)).toBe(0.5);
+
+ const x2 = NumberValueObject.create(3);
+ const result3 = testFunction.calculate(x2, alpha2, beta2, cumulative, A, B);
+ expect(getObjectValue(result3)).toBe(0);
+
+ const alpha3 = NumberValueObject.create(520);
+ const beta3 = NumberValueObject.create(520);
+ const result4 = testFunction.calculate(x, alpha3, beta3, cumulative, A, B);
+ expect(getObjectValue(result4)).toBe(12.86240966652393);
+
+ const alpha4 = NumberValueObject.create(350);
+ const beta4 = NumberValueObject.create(350);
+ const result5 = testFunction.calculate(x, alpha4, beta4, cumulative, A, B);
+ expect(getObjectValue(result5)).toBe(10.551251636711884);
+
+ const alpha5 = NumberValueObject.create(0.1);
+ const beta5 = NumberValueObject.create(0.1);
+ const result6 = testFunction.calculate(x, alpha5, beta5, cumulative, A, B);
+ expect(getObjectValue(result6)).toBe(0.08831513898907835);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const x2 = NumberValueObject.create(2);
+ const A2 = NullValueObject.create();
+ const B2 = NullValueObject.create();
+ const result2 = testFunction.calculate(x2, alpha, beta, cumulative, A2, B2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const cumulative = BooleanValueObject.create(true);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(x, alpha, beta, cumulative, A, B);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0, ErrorType.VALUE, 0.00028348362316367936, 0, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, 0.9745907595394001, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/beta-dist/index.ts b/packages/engine-formula/src/functions/statistical/beta-dist/index.ts
new file mode 100644
index 0000000000..522dd30ec0
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/beta-dist/index.ts
@@ -0,0 +1,129 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { betaCDF, betaPDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class BetaDist extends BaseFunction {
+ override minParams = 4;
+
+ override maxParams = 6;
+
+ override calculate(
+ x: BaseValueObject,
+ alpha: BaseValueObject,
+ beta: BaseValueObject,
+ cumulative: BaseValueObject,
+ A?: BaseValueObject,
+ B?: BaseValueObject
+ ): BaseValueObject {
+ let _A = A ?? NumberValueObject.create(0);
+ let _B = B ?? NumberValueObject.create(1);
+
+ if (_A.isNull()) {
+ _A = NumberValueObject.create(0);
+ }
+
+ if (_B.isNull()) {
+ _B = NumberValueObject.create(1);
+ }
+
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getRowCount() : 1,
+ beta.isArray() ? (beta as ArrayValueObject).getRowCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getRowCount() : 1,
+ _A.isArray() ? (_A as ArrayValueObject).getRowCount() : 1,
+ _B.isArray() ? (_B as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getColumnCount() : 1,
+ beta.isArray() ? (beta as ArrayValueObject).getColumnCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getColumnCount() : 1,
+ _A.isArray() ? (_A as ArrayValueObject).getColumnCount() : 1,
+ _B.isArray() ? (_B as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType.NA));
+ const betaArray = expandArrayValueObject(maxRowLength, maxColumnLength, beta, ErrorValueObject.create(ErrorType.NA));
+ const cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType.NA));
+ const AArray = expandArrayValueObject(maxRowLength, maxColumnLength, _A, ErrorValueObject.create(ErrorType.NA));
+ const BArray = expandArrayValueObject(maxRowLength, maxColumnLength, _B, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const alphaObject = alphaArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const betaObject = betaArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const AObject = AArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const BObject = BArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, alphaObject, betaObject, cumulativeObject, AObject, BObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ alphaObject: BaseValueObject,
+ betaObject: BaseValueObject,
+ cumulativeObject: BaseValueObject,
+ AObject: BaseValueObject,
+ BObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, alphaObject, betaObject, cumulativeObject, AObject, BObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _alphaObject, _betaObject, _cumulativeObject, _AObject, _BObject] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const alphaValue = +_alphaObject.getValue();
+ const betaValue = +_betaObject.getValue();
+ const cumulativeValue = +_cumulativeObject.getValue();
+ const AValue = +_AObject.getValue();
+ const BValue = +_BObject.getValue();
+
+ if (alphaValue <= 0 || betaValue <= 0 || xValue < AValue || xValue > BValue || AValue === BValue) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result;
+
+ if (cumulativeValue) {
+ result = betaCDF((xValue - AValue) / (BValue - AValue), alphaValue, betaValue);
+ } else {
+ result = betaPDF((xValue - AValue) / (BValue - AValue), alphaValue, betaValue) / (BValue - AValue);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/beta-inv/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/beta-inv/__tests__/index.spec.ts
new file mode 100644
index 0000000000..cb46b84456
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/beta-inv/__tests__/index.spec.ts
@@ -0,0 +1,169 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { BetaInv } from '../index';
+
+describe('Test betaInv function', () => {
+ const testFunction = new BetaInv(FUNCTION_NAMES_STATISTICAL.BETA_INV);
+
+ describe('BetaInv', () => {
+ it('Value is normal', () => {
+ const probability = NumberValueObject.create(0.685470581);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(1.9999999999920839);
+
+ const result2 = testFunction.calculate(probability, alpha, beta);
+ expect(getObjectValue(result2)).toBe(0.49999999999604194);
+ });
+
+ it('Alpha and beta value test', () => {
+ const probability = NumberValueObject.create(0.685470581);
+ const alpha = NumberValueObject.create(0);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const alpha2 = NumberValueObject.create(8);
+ const beta2 = NumberValueObject.create(0);
+ const result2 = testFunction.calculate(probability, alpha2, beta2, A, B);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+
+ const alpha3 = NumberValueObject.create(1);
+ const beta3 = NumberValueObject.create(1);
+ const result3 = testFunction.calculate(probability, alpha3, beta3, A, B);
+ expect(getObjectValue(result3)).toBe(2.3709411619999994);
+ });
+
+ it('Probability and A and B value test', () => {
+ const probability = NumberValueObject.create(2);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const probability2 = NumberValueObject.create(1);
+ const A2 = NumberValueObject.create(1);
+ const B2 = NumberValueObject.create(3);
+ const result2 = testFunction.calculate(probability2, alpha, beta, A2, B2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+
+ const probability3 = NumberValueObject.create(3);
+ const result3 = testFunction.calculate(probability3, alpha, beta, A2, B2);
+ expect(getObjectValue(result3)).toBe(ErrorType.NUM);
+ });
+
+ it('A and B value test', () => {
+ const probability = NumberValueObject.create(0.685470581);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const A2 = NumberValueObject.create(-1);
+ const B2 = NumberValueObject.create(-0.1);
+ const result2 = testFunction.calculate(probability, alpha, beta, A2, B2);
+ expect(getObjectValue(result2)).toBe(-0.5500000000035623);
+ });
+
+ it('Value is normal string', () => {
+ const probability = StringValueObject.create('test');
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const probability = BooleanValueObject.create(true);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const probability = NullValueObject.create();
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const probability2 = NumberValueObject.create(0.685470581);
+ const A2 = NullValueObject.create();
+ const B2 = NullValueObject.create();
+ const result2 = testFunction.calculate(probability2, alpha, beta, A2, B2);
+ expect(getObjectValue(result2)).toBe(0.49999999999604194);
+ });
+
+ it('Value is error', () => {
+ const probability = ErrorValueObject.create(ErrorType.NAME);
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const probability = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const alpha = NumberValueObject.create(8);
+ const beta = NumberValueObject.create(10);
+ const A = NumberValueObject.create(1);
+ const B = NumberValueObject.create(3);
+ const result = testFunction.calculate(probability, alpha, beta, A, B);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/beta-inv/index.ts b/packages/engine-formula/src/functions/statistical/beta-inv/index.ts
new file mode 100644
index 0000000000..42009fc281
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/beta-inv/index.ts
@@ -0,0 +1,116 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { betaINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class BetaInv extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 5;
+
+ override calculate(
+ probability: BaseValueObject,
+ alpha: BaseValueObject,
+ beta: BaseValueObject,
+ A?: BaseValueObject,
+ B?: BaseValueObject
+ ): BaseValueObject {
+ let _A = A ?? NumberValueObject.create(0);
+ let _B = B ?? NumberValueObject.create(1);
+
+ if (_A.isNull()) {
+ _A = NumberValueObject.create(0);
+ }
+
+ if (_B.isNull()) {
+ _B = NumberValueObject.create(1);
+ }
+
+ const maxRowLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getRowCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getRowCount() : 1,
+ beta.isArray() ? (beta as ArrayValueObject).getRowCount() : 1,
+ _A.isArray() ? (_A as ArrayValueObject).getRowCount() : 1,
+ _B.isArray() ? (_B as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getColumnCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getColumnCount() : 1,
+ beta.isArray() ? (beta as ArrayValueObject).getColumnCount() : 1,
+ _A.isArray() ? (_A as ArrayValueObject).getColumnCount() : 1,
+ _B.isArray() ? (_B as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType.NA));
+ const alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType.NA));
+ const betaArray = expandArrayValueObject(maxRowLength, maxColumnLength, beta, ErrorValueObject.create(ErrorType.NA));
+ const AArray = expandArrayValueObject(maxRowLength, maxColumnLength, _A, ErrorValueObject.create(ErrorType.NA));
+ const BArray = expandArrayValueObject(maxRowLength, maxColumnLength, _B, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
+ const alphaObject = alphaArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const betaObject = betaArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const AObject = AArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const BObject = BArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(probabilityObject, alphaObject, betaObject, AObject, BObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ probabilityObject: BaseValueObject,
+ alphaObject: BaseValueObject,
+ betaObject: BaseValueObject,
+ AObject: BaseValueObject,
+ BObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, alphaObject, betaObject, AObject, BObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_probabilityObject, _alphaObject, _betaObject, _AObject, _BObject] = variants as BaseValueObject[];
+
+ const probabilityValue = +_probabilityObject.getValue();
+ const alphaValue = +_alphaObject.getValue();
+ const betaValue = +_betaObject.getValue();
+ const AValue = +_AObject.getValue();
+ const BValue = +_BObject.getValue();
+
+ if (alphaValue <= 0 || betaValue <= 0 || probabilityValue <= 0 || probabilityValue >= 1 || AValue >= BValue) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = betaINV(probabilityValue, alphaValue, betaValue) * (BValue - AValue) + AValue;
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/binom-dist-range/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/binom-dist-range/__tests__/index.spec.ts
new file mode 100644
index 0000000000..22d41c7bcb
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/binom-dist-range/__tests__/index.spec.ts
@@ -0,0 +1,146 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { BinomDistRange } from '../index';
+
+describe('Test binomDistRange function', () => {
+ const testFunction = new BinomDistRange(FUNCTION_NAMES_STATISTICAL.BINOM_DIST_RANGE);
+
+ describe('BinomDistRange', () => {
+ it('Value is normal', () => {
+ const trials = NumberValueObject.create(60);
+ const probabilityS = NumberValueObject.create(0.75);
+ const numberS = NumberValueObject.create(45);
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toBe(0.5236297934718872);
+
+ const result2 = testFunction.calculate(trials, probabilityS, numberS);
+ expect(getObjectValue(result2)).toBe(0.11822800461154298);
+ });
+
+ it('Trials and numberS and numberS2 value test', () => {
+ const trials = NumberValueObject.create(-60);
+ const probabilityS = NumberValueObject.create(0.75);
+ const numberS = NumberValueObject.create(45);
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const trials2 = NumberValueObject.create(60);
+ const numberS3 = NumberValueObject.create(-45);
+ const result2 = testFunction.calculate(trials2, probabilityS, numberS3, numberS2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+
+ const numberS4 = NumberValueObject.create(-50);
+ const result3 = testFunction.calculate(trials2, probabilityS, numberS, numberS4);
+ expect(getObjectValue(result3)).toBe(ErrorType.NUM);
+
+ const numberS5 = NumberValueObject.create(65);
+ const result4 = testFunction.calculate(trials2, probabilityS, numberS, numberS5);
+ expect(getObjectValue(result4)).toBe(ErrorType.NUM);
+
+ const result5 = testFunction.calculate(trials2, probabilityS, numberS5, numberS2);
+ expect(getObjectValue(result5)).toBe(ErrorType.NUM);
+
+ const result6 = testFunction.calculate(trials2, probabilityS, numberS2, numberS);
+ expect(getObjectValue(result6)).toBe(ErrorType.NUM);
+ });
+
+ it('ProbabilityS value test', () => {
+ const trials = NumberValueObject.create(60);
+ const probabilityS = NumberValueObject.create(-0.75);
+ const numberS = NumberValueObject.create(45);
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const probabilityS2 = NumberValueObject.create(1.75);
+ const result2 = testFunction.calculate(trials, probabilityS2, numberS, numberS2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const trials = StringValueObject.create('test');
+ const probabilityS = NumberValueObject.create(0.75);
+ const numberS = NumberValueObject.create(45);
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const trials = NumberValueObject.create(60);
+ const probabilityS = NumberValueObject.create(0.75);
+ const numberS = BooleanValueObject.create(true);
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toBe(0.9548325185075196);
+ });
+
+ it('Value is null', () => {
+ const trials = NumberValueObject.create(60);
+ const probabilityS = NumberValueObject.create(0.75);
+ const numberS = NullValueObject.create();
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toBe(0.9548325185075196);
+
+ const result2 = testFunction.calculate(trials, probabilityS, numberS2, numberS);
+ expect(getObjectValue(result2)).toBe(0.04071929032886058);
+ });
+
+ it('Value is error', () => {
+ const trials = ErrorValueObject.create(ErrorType.NAME);
+ const probabilityS = NumberValueObject.create(0.75);
+ const numberS = NumberValueObject.create(45);
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const trials = NumberValueObject.create(60);
+ const probabilityS = NumberValueObject.create(0.75);
+ const numberS = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const numberS2 = NumberValueObject.create(50);
+ const result = testFunction.calculate(trials, probabilityS, numberS, numberS2);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.9548325185075196, ErrorType.VALUE, 0.9548325185075196, 0.9548325185075196, 0.9548325185075196, 0.9548325185075196],
+ [0.9548325185075196, ErrorType.NUM, 0.9548325185075196, ErrorType.VALUE, ErrorType.NUM, 0.9548325185075196],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/binom-dist-range/index.ts b/packages/engine-formula/src/functions/statistical/binom-dist-range/index.ts
new file mode 100644
index 0000000000..013e1a5bec
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/binom-dist-range/index.ts
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { binomialPDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class BinomDistRange extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 4;
+
+ override calculate(
+ trials: BaseValueObject,
+ probabilityS: BaseValueObject,
+ numberS: BaseValueObject,
+ numberS2?: BaseValueObject
+ ): BaseValueObject {
+ let _numberS2 = numberS2 ?? numberS;
+
+ if (_numberS2.isNull()) {
+ _numberS2 = numberS;
+ }
+
+ const maxRowLength = Math.max(
+ trials.isArray() ? (trials as ArrayValueObject).getRowCount() : 1,
+ probabilityS.isArray() ? (probabilityS as ArrayValueObject).getRowCount() : 1,
+ numberS.isArray() ? (numberS as ArrayValueObject).getRowCount() : 1,
+ _numberS2.isArray() ? (_numberS2 as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ trials.isArray() ? (trials as ArrayValueObject).getColumnCount() : 1,
+ probabilityS.isArray() ? (probabilityS as ArrayValueObject).getColumnCount() : 1,
+ numberS.isArray() ? (numberS as ArrayValueObject).getColumnCount() : 1,
+ _numberS2.isArray() ? (_numberS2 as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const trialsArray = expandArrayValueObject(maxRowLength, maxColumnLength, trials, ErrorValueObject.create(ErrorType.NA));
+ const probabilitySArray = expandArrayValueObject(maxRowLength, maxColumnLength, probabilityS, ErrorValueObject.create(ErrorType.NA));
+ const numberSArray = expandArrayValueObject(maxRowLength, maxColumnLength, numberS, ErrorValueObject.create(ErrorType.NA));
+ const numberS2Array = expandArrayValueObject(maxRowLength, maxColumnLength, _numberS2, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = trialsArray.mapValue((trialsObject, rowIndex, columnIndex) => {
+ const probabilitySObject = probabilitySArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const numberSObject = numberSArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const numberS2Object = numberS2Array.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(trialsObject, probabilitySObject, numberSObject, numberS2Object);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ trialsObject: BaseValueObject,
+ probabilitySObject: BaseValueObject,
+ numberSObject: BaseValueObject,
+ numberS2Object: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(trialsObject, probabilitySObject, numberSObject, numberS2Object);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_trialsObject, _probabilitySObject, _numberSObject, _numberS2Object] = variants as BaseValueObject[];
+
+ const trialsValue = Math.floor(+_trialsObject.getValue());
+ const probabilitySValue = +_probabilitySObject.getValue();
+ const numberSValue = Math.floor(+_numberSObject.getValue());
+ const numberS2Value = Math.floor(+_numberS2Object.getValue());
+
+ if (
+ trialsValue < 0 ||
+ probabilitySValue < 0 ||
+ probabilitySValue > 1 ||
+ numberSValue < 0 ||
+ numberSValue > trialsValue ||
+ numberS2Value < 0 ||
+ numberS2Value < numberSValue ||
+ numberS2Value > trialsValue
+ ) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result = 0;
+
+ for (let i = numberSValue; i <= numberS2Value; i++) {
+ result += binomialPDF(i, trialsValue, probabilitySValue);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/binom-dist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/binom-dist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..f102c3f06b
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/binom-dist/__tests__/index.spec.ts
@@ -0,0 +1,146 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { BinomDist } from '../index';
+
+describe('Test binomDist function', () => {
+ const testFunction = new BinomDist(FUNCTION_NAMES_STATISTICAL.BINOM_DIST);
+
+ describe('BinomDist', () => {
+ it('Value is normal', () => {
+ const numberS = NumberValueObject.create(6);
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(0.828125);
+ });
+
+ it('NumberS and trials value test', () => {
+ const numberS = NumberValueObject.create(-6);
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const numberS2 = NumberValueObject.create(11);
+ const trials2 = NumberValueObject.create(10);
+ const result2 = testFunction.calculate(numberS2, trials2, probabilityS, cumulative);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('ProbabilityS value test', () => {
+ const numberS = NumberValueObject.create(6);
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(-0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const probabilityS2 = NumberValueObject.create(1.5);
+ const result2 = testFunction.calculate(numberS, trials, probabilityS2, cumulative);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Cumulative value test', () => {
+ const numberS = NumberValueObject.create(6);
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(false);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(0.205078125);
+
+ const numberS2 = NumberValueObject.create(0);
+ const trials2 = NumberValueObject.create(0);
+ const probabilityS2 = NumberValueObject.create(0);
+ const result2 = testFunction.calculate(numberS2, trials2, probabilityS2, cumulative);
+ expect(getObjectValue(result2)).toBe(1);
+
+ const numberS3 = NumberValueObject.create(1);
+ const trials3 = NumberValueObject.create(1);
+ const result3 = testFunction.calculate(numberS3, trials3, probabilityS2, cumulative);
+ expect(getObjectValue(result3)).toBe(0);
+ });
+
+ it('Value is normal string', () => {
+ const numberS = StringValueObject.create('test');
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const numberS = BooleanValueObject.create(true);
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(0.0107421875);
+ });
+
+ it('Value is null', () => {
+ const numberS = NullValueObject.create();
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(0.0009765625);
+ });
+
+ it('Value is error', () => {
+ const numberS = ErrorValueObject.create(ErrorType.NAME);
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const numberS = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const trials = NumberValueObject.create(10);
+ const probabilityS = NumberValueObject.create(0.5);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(numberS, trials, probabilityS, cumulative);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.0107421875, ErrorType.VALUE, 0.0107421875, 0.0107421875, 0.0009765625, 0.0009765625],
+ [0.0009765625, ErrorType.NUM, 0.0546875, ErrorType.VALUE, ErrorType.NUM, 0.0009765625],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/binom-dist/index.ts b/packages/engine-formula/src/functions/statistical/binom-dist/index.ts
new file mode 100644
index 0000000000..3c30e58716
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/binom-dist/index.ts
@@ -0,0 +1,104 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { binomialCDF, binomialPDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class BinomDist extends BaseFunction {
+ override minParams = 4;
+
+ override maxParams = 4;
+
+ override calculate(
+ numberS: BaseValueObject,
+ trials: BaseValueObject,
+ probabilityS: BaseValueObject,
+ cumulative: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ numberS.isArray() ? (numberS as ArrayValueObject).getRowCount() : 1,
+ trials.isArray() ? (trials as ArrayValueObject).getRowCount() : 1,
+ probabilityS.isArray() ? (probabilityS as ArrayValueObject).getRowCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ numberS.isArray() ? (numberS as ArrayValueObject).getColumnCount() : 1,
+ trials.isArray() ? (trials as ArrayValueObject).getColumnCount() : 1,
+ probabilityS.isArray() ? (probabilityS as ArrayValueObject).getColumnCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const numberSArray = expandArrayValueObject(maxRowLength, maxColumnLength, numberS, ErrorValueObject.create(ErrorType.NA));
+ const trialsArray = expandArrayValueObject(maxRowLength, maxColumnLength, trials, ErrorValueObject.create(ErrorType.NA));
+ const probabilitySArray = expandArrayValueObject(maxRowLength, maxColumnLength, probabilityS, ErrorValueObject.create(ErrorType.NA));
+ const cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = numberSArray.mapValue((numberSObject, rowIndex, columnIndex) => {
+ const trialsObject = trialsArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const probabilitySObject = probabilitySArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(numberSObject, trialsObject, probabilitySObject, cumulativeObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ numberSObject: BaseValueObject,
+ trialsObject: BaseValueObject,
+ probabilitySObject: BaseValueObject,
+ cumulativeObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(numberSObject, trialsObject, probabilitySObject, cumulativeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_numberSObject, _trialsObject, _probabilitySObject, _cumulativeObject] = variants as BaseValueObject[];
+
+ const numberSValue = Math.floor(+_numberSObject.getValue());
+ const trialsValue = Math.floor(+_trialsObject.getValue());
+ const probabilitySValue = +_probabilitySObject.getValue();
+ const cumulativeValue = +_cumulativeObject.getValue();
+
+ if (numberSValue < 0 || numberSValue > trialsValue || probabilitySValue < 0 || probabilitySValue > 1) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result;
+
+ if (cumulativeValue) {
+ result = binomialCDF(numberSValue, trialsValue, probabilitySValue);
+ } else {
+ result = binomialPDF(numberSValue, trialsValue, probabilitySValue);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/binom-inv/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/binom-inv/__tests__/index.spec.ts
new file mode 100644
index 0000000000..bbed1edce7
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/binom-inv/__tests__/index.spec.ts
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { BinomInv } from '../index';
+
+describe('Test binomInv function', () => {
+ const testFunction = new BinomInv(FUNCTION_NAMES_STATISTICAL.BINOM_INV);
+
+ describe('BinomInv', () => {
+ it('Value is normal', () => {
+ const trials = NumberValueObject.create(6);
+ const probabilityS = NumberValueObject.create(0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toBe(4);
+ });
+
+ it('Trials value test', () => {
+ const trials = NumberValueObject.create(-6);
+ const probabilityS = NumberValueObject.create(0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('ProbabilityS value test', () => {
+ const trials = NumberValueObject.create(6);
+ const probabilityS = NumberValueObject.create(-0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const probabilityS2 = NumberValueObject.create(1.5);
+ const result2 = testFunction.calculate(trials, probabilityS2, alpha);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const trials = StringValueObject.create('test');
+ const probabilityS = NumberValueObject.create(0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const trials = BooleanValueObject.create(true);
+ const probabilityS = NumberValueObject.create(0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is null', () => {
+ const trials = NullValueObject.create();
+ const probabilityS = NumberValueObject.create(0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const trials = ErrorValueObject.create(ErrorType.NAME);
+ const probabilityS = NumberValueObject.create(0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const trials = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const probabilityS = NumberValueObject.create(0.5);
+ const alpha = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(trials, probabilityS, alpha);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1, ErrorType.VALUE, 1, 1, 0, 0],
+ [0, 53, 1, ErrorType.VALUE, ErrorType.NUM, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/binom-inv/index.ts b/packages/engine-formula/src/functions/statistical/binom-inv/index.ts
new file mode 100644
index 0000000000..b8216861dc
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/binom-inv/index.ts
@@ -0,0 +1,99 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { binomialCDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class BinomInv extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(
+ trials: BaseValueObject,
+ probabilityS: BaseValueObject,
+ alpha: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ trials.isArray() ? (trials as ArrayValueObject).getRowCount() : 1,
+ probabilityS.isArray() ? (probabilityS as ArrayValueObject).getRowCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ trials.isArray() ? (trials as ArrayValueObject).getColumnCount() : 1,
+ probabilityS.isArray() ? (probabilityS as ArrayValueObject).getColumnCount() : 1,
+ alpha.isArray() ? (alpha as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const trialsArray = expandArrayValueObject(maxRowLength, maxColumnLength, trials, ErrorValueObject.create(ErrorType.NA));
+ const probabilitySArray = expandArrayValueObject(maxRowLength, maxColumnLength, probabilityS, ErrorValueObject.create(ErrorType.NA));
+ const alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = trialsArray.mapValue((trialsObject, rowIndex, columnIndex) => {
+ const probabilitySObject = probabilitySArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const alphaObject = alphaArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(trialsObject, probabilitySObject, alphaObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ trialsObject: BaseValueObject,
+ probabilitySObject: BaseValueObject,
+ alphaObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(trialsObject, probabilitySObject, alphaObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_trialsObject, _probabilitySObject, _alphaObject] = variants as BaseValueObject[];
+
+ const trialsValue = Math.floor(+_trialsObject.getValue());
+ const probabilitySValue = +_probabilitySObject.getValue();
+ const alphaValue = +_alphaObject.getValue();
+
+ if (trialsValue < 0 || probabilitySValue <= 0 || probabilitySValue >= 1 || alphaValue <= 0 || alphaValue >= 1) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result = 0;
+
+ while (result <= trialsValue) {
+ if (binomialCDF(result, trialsValue, probabilitySValue) >= alphaValue) {
+ break;
+ }
+
+ result++;
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/chisq-dist-rt/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/chisq-dist-rt/__tests__/index.spec.ts
new file mode 100644
index 0000000000..f9da9a22b3
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-dist-rt/__tests__/index.spec.ts
@@ -0,0 +1,98 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ChisqDistRt } from '../index';
+
+describe('Test chisqDistRt function', () => {
+ const testFunction = new ChisqDistRt(FUNCTION_NAMES_STATISTICAL.CHISQ_DIST_RT);
+
+ describe('ChisqDistRt', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, degFreedom);
+ expect(getObjectValue(result)).toBe(0.4795001221869758);
+ });
+
+ it('DegFreedom value test', () => {
+ const x = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(0);
+ const result = testFunction.calculate(x, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom2 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(x, degFreedom2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, degFreedom);
+ expect(getObjectValue(result)).toBe(0.31731050786294357);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, degFreedom);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(x, degFreedom);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.31731050786294357, ErrorType.VALUE, 0.2674070380711471, 0.31731050786294357, 1, 1],
+ [1, 0, 0.12608955395262833, ErrorType.VALUE, ErrorType.NUM, 1],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/chisq-dist-rt/index.ts b/packages/engine-formula/src/functions/statistical/chisq-dist-rt/index.ts
new file mode 100644
index 0000000000..0a4305155c
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-dist-rt/index.ts
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { chisquareCDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ChisqDistRt extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(
+ x: BaseValueObject,
+ degFreedom: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, degFreedomObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ degFreedomObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedomObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _degFreedomObject] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const degFreedomValue = Math.floor(+_degFreedomObject.getValue());
+
+ if (xValue < 0 || degFreedomValue < 1 || degFreedomValue > 10 ** 10) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = 1 - chisquareCDF(xValue, degFreedomValue);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/chisq-dist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/chisq-dist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..bc84021835
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-dist/__tests__/index.spec.ts
@@ -0,0 +1,118 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ChisqDist } from '../index';
+
+describe('Test chisqDist function', () => {
+ const testFunction = new ChisqDist(FUNCTION_NAMES_STATISTICAL.CHISQ_DIST);
+
+ describe('ChisqDist', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toBe(0.5204998778130242);
+ });
+
+ it('DegFreedom value test', () => {
+ const x = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(0);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom2 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(x, degFreedom2, cumulative);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Cumulative value test', () => {
+ const x = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(false);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toBe(0.4393912894677035);
+
+ const x2 = NumberValueObject.create(0);
+ const degFreedom2 = NumberValueObject.create(2);
+ const result2 = testFunction.calculate(x2, degFreedom2, cumulative);
+ expect(getObjectValue(result2)).toBe(0.5);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const degFreedom = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const degFreedom = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toBe(0.6826894921370564);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const degFreedom = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom, cumulative);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.6826894921370564, ErrorType.VALUE, 0.7325929619288529, 0.6826894921370564, 0, 0],
+ [0, 1, 0.8739104460473717, ErrorType.VALUE, ErrorType.NUM, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/chisq-dist/index.ts b/packages/engine-formula/src/functions/statistical/chisq-dist/index.ts
new file mode 100644
index 0000000000..15f7071101
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-dist/index.ts
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { chisquareCDF, chisquarePDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ChisqDist extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(
+ x: BaseValueObject,
+ degFreedom: BaseValueObject,
+ cumulative: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getRowCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getColumnCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType.NA));
+ const cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, degFreedomObject, cumulativeObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ degFreedomObject: BaseValueObject,
+ cumulativeObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedomObject, cumulativeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _degFreedomObject, _cumulativeObject] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const degFreedomValue = Math.floor(+_degFreedomObject.getValue());
+ const cumulativeValue = +_cumulativeObject.getValue();
+
+ if (xValue < 0 || degFreedomValue < 1 || degFreedomValue > 10 ** 10) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result;
+
+ if (cumulativeValue) {
+ result = chisquareCDF(xValue, degFreedomValue);
+ } else {
+ result = chisquarePDF(xValue, degFreedomValue);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/chisq-inv-rt/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/chisq-inv-rt/__tests__/index.spec.ts
new file mode 100644
index 0000000000..0df353c249
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-inv-rt/__tests__/index.spec.ts
@@ -0,0 +1,109 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ChisqInvRt } from '../index';
+
+describe('Test chisqInvRt function', () => {
+ const testFunction = new ChisqInvRt(FUNCTION_NAMES_STATISTICAL.CHISQ_INV_RT);
+
+ describe('ChisqInvRt', () => {
+ it('Value is normal', () => {
+ const probability = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(0.45493642311961857);
+ });
+
+ it('Probability value test', () => {
+ const probability = NumberValueObject.create(-0.5);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const probability2 = NumberValueObject.create(1.5);
+ const result2 = testFunction.calculate(probability2, degFreedom);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('DegFreedom value test', () => {
+ const probability = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(0);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom2 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(probability, degFreedom2);
+ expect(getObjectValue(result2)).toBe(10000000002.186049);
+ });
+
+ it('Value is normal string', () => {
+ const probability = StringValueObject.create('test');
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const probability = BooleanValueObject.create(true);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is null', () => {
+ const probability = NullValueObject.create();
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const probability = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const probability = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0, ErrorType.VALUE, ErrorType.NUM, 0, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/chisq-inv-rt/index.ts b/packages/engine-formula/src/functions/statistical/chisq-inv-rt/index.ts
new file mode 100644
index 0000000000..63d1b2b087
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-inv-rt/index.ts
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { chisquareINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ChisqInvRt extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(
+ probability: BaseValueObject,
+ degFreedom: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getRowCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getColumnCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType.NA));
+ const degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
+ const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(probabilityObject, degFreedomObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ probabilityObject: BaseValueObject,
+ degFreedomObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedomObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_probabilityObject, _degFreedomObject] = variants as BaseValueObject[];
+
+ const probabilityValue = +_probabilityObject.getValue();
+ const degFreedomValue = Math.floor(+_degFreedomObject.getValue());
+
+ if (probabilityValue < 0 || probabilityValue > 1 || degFreedomValue < 1) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = chisquareINV(1 - probabilityValue, degFreedomValue);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/chisq-inv/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/chisq-inv/__tests__/index.spec.ts
new file mode 100644
index 0000000000..d764202397
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-inv/__tests__/index.spec.ts
@@ -0,0 +1,119 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ChisqInv } from '../index';
+
+describe('Test chisqInv function', () => {
+ const testFunction = new ChisqInv(FUNCTION_NAMES_STATISTICAL.CHISQ_INV);
+
+ describe('ChisqInv', () => {
+ it('Value is normal', () => {
+ const probability = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(0.45493642311961857);
+ });
+
+ it('Probability value test', () => {
+ const probability = NumberValueObject.create(-0.5);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const probability2 = NumberValueObject.create(1.5);
+ const result2 = testFunction.calculate(probability2, degFreedom);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('DegFreedom value test', () => {
+ const probability = NumberValueObject.create(0.5);
+ const degFreedom = NumberValueObject.create(0);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom2 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(probability, degFreedom2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+
+ const probability2 = NumberValueObject.create(0.1);
+ const degFreedom3 = NumberValueObject.create(3);
+ const result3 = testFunction.calculate(probability2, degFreedom3);
+ expect(getObjectValue(result3)).toBe(0.5843743741551812);
+
+ const probability3 = NumberValueObject.create(0.9);
+ const degFreedom4 = NumberValueObject.create(1);
+ const result4 = testFunction.calculate(probability3, degFreedom4);
+ expect(getObjectValue(result4)).toBe(2.705543454096032);
+ });
+
+ it('Value is normal string', () => {
+ const probability = StringValueObject.create('test');
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const probability = BooleanValueObject.create(true);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const probability = NullValueObject.create();
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const probability = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const probability = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom = NumberValueObject.create(1);
+ const result = testFunction.calculate(probability, degFreedom);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, 0, 0],
+ [0, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/chisq-inv/index.ts b/packages/engine-formula/src/functions/statistical/chisq-inv/index.ts
new file mode 100644
index 0000000000..7a3d569de1
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-inv/index.ts
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { chisquareINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ChisqInv extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(
+ probability: BaseValueObject,
+ degFreedom: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getRowCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getColumnCount() : 1,
+ degFreedom.isArray() ? (degFreedom as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType.NA));
+ const degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
+ const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(probabilityObject, degFreedomObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ probabilityObject: BaseValueObject,
+ degFreedomObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedomObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_probabilityObject, _degFreedomObject] = variants as BaseValueObject[];
+
+ const probabilityValue = +_probabilityObject.getValue();
+ const degFreedomValue = Math.floor(+_degFreedomObject.getValue());
+
+ if (probabilityValue < 0 || probabilityValue > 1 || degFreedomValue < 1 || degFreedomValue > 10 ** 10) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = chisquareINV(probabilityValue, degFreedomValue);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/chisq-test/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/chisq-test/__tests__/index.spec.ts
new file mode 100644
index 0000000000..ed422c8510
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-test/__tests__/index.spec.ts
@@ -0,0 +1,359 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ChisqTest } from '../index';
+
+describe('Test chisqTest function', () => {
+ const testFunction = new ChisqTest(FUNCTION_NAMES_STATISTICAL.CHISQ_TEST);
+
+ describe('ChisqTest', () => {
+ it('Value is normal', () => {
+ const actualRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(0.0003081920170082686);
+ });
+
+ it('Value length is equal to 1', () => {
+ const actualRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value length is not equal', () => {
+ const actualRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value is error', () => {
+ const actualRange = ErrorValueObject.create(ErrorType.NAME);
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const actualRange2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange2 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(actualRange2, expectedRange2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+
+ const actualRange3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(actualRange3, expectedRange3);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const actualRange4 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange4 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(actualRange4, expectedRange4);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null', () => {
+ const actualRange = NullValueObject.create();
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const actualRange2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange2 = NullValueObject.create();
+ const result2 = testFunction.calculate(actualRange2, expectedRange2);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is can not calculate', () => {
+ const actualRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, null],
+ [11, 'test'],
+ [10, true],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [false, 47.65],
+ [null, 18.44],
+ ['test', 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Calculate df test', () => {
+ const actualRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35, 11, 25, 10, 23],
+ ]),
+ rowCount: 1,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(0.0063762422150260845);
+
+ const actualRange2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ [35],
+ [11],
+ [25],
+ [10],
+ [23],
+ ]),
+ rowCount: 6,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(actualRange2, expectedRange);
+ expect(getObjectValue(result2)).toBe(0.0063762422150260845);
+ });
+
+ it('ExpectedRange value has 0', () => {
+ const actualRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const expectedRange = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 0],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(actualRange, expectedRange);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/chisq-test/index.ts b/packages/engine-formula/src/functions/statistical/chisq-test/index.ts
new file mode 100644
index 0000000000..32b8793c13
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/chisq-test/index.ts
@@ -0,0 +1,121 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { chisquareCDF, getTwoArrayNumberValues } from '../../../basics/statistical';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ChisqTest extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(actualRange: BaseValueObject, expectedRange: BaseValueObject): BaseValueObject {
+ const actualRangeRowCount = actualRange.isArray() ? (actualRange as ArrayValueObject).getRowCount() : 1;
+ const actualRangeColumnCount = actualRange.isArray() ? (actualRange as ArrayValueObject).getColumnCount() : 1;
+
+ const expectedRangeRowCount = expectedRange.isArray() ? (expectedRange as ArrayValueObject).getRowCount() : 1;
+ const expectedRangeColumnCount = expectedRange.isArray() ? (expectedRange as ArrayValueObject).getColumnCount() : 1;
+
+ let _actualRange = actualRange;
+
+ if (actualRange.isArray() && actualRangeRowCount === 1 && actualRangeColumnCount === 1) {
+ _actualRange = (actualRange as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_actualRange.isError()) {
+ return _actualRange;
+ }
+
+ let _expectedRange = expectedRange;
+
+ if (expectedRange.isArray() && expectedRangeRowCount === 1 && expectedRangeColumnCount === 1) {
+ _expectedRange = (expectedRange as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_expectedRange.isError()) {
+ return _expectedRange;
+ }
+
+ if (actualRangeRowCount * actualRangeColumnCount === 1 || expectedRangeRowCount * expectedRangeColumnCount === 1) {
+ if (_actualRange.isNull() || _expectedRange.isNull()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ if (actualRangeRowCount * actualRangeColumnCount !== expectedRangeRowCount * expectedRangeColumnCount) {
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ const {
+ isError,
+ errorObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ } = getTwoArrayNumberValues(
+ actualRange,
+ expectedRange,
+ actualRangeRowCount * actualRangeColumnCount,
+ actualRangeColumnCount,
+ expectedRangeColumnCount
+ );
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ if (noCalculate) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return this._getResult(array1Values, array2Values, actualRangeRowCount, actualRangeColumnCount);
+ }
+
+ private _getResult(
+ actualRangeValues: number[],
+ expectedRangeValues: number[],
+ actualRangeRowCount: number,
+ actualRangeColumnCount: number
+ ): BaseValueObject {
+ let sumxmy2 = 0;
+
+ for (let i = 0; i < actualRangeValues.length; i++) {
+ if (expectedRangeValues[i] === 0) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ sumxmy2 += (actualRangeValues[i] - expectedRangeValues[i]) ** 2 / expectedRangeValues[i];
+ }
+
+ let df = (actualRangeRowCount - 1) * (actualRangeColumnCount - 1);
+
+ if (actualRangeRowCount === 1) {
+ df = actualRangeColumnCount - 1;
+ } else if (actualRangeColumnCount === 1) {
+ df = actualRangeRowCount - 1;
+ }
+
+ const result = 1 - chisquareCDF(sumxmy2, df);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/confidence-norm/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/confidence-norm/__tests__/index.spec.ts
new file mode 100644
index 0000000000..5d05d42c30
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/confidence-norm/__tests__/index.spec.ts
@@ -0,0 +1,121 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ConfidenceNorm } from '../index';
+
+describe('Test confidenceNorm function', () => {
+ const testFunction = new ConfidenceNorm(FUNCTION_NAMES_STATISTICAL.CONFIDENCE_NORM);
+
+ describe('ConfidenceNorm', () => {
+ it('Value is normal', () => {
+ const alpha = NumberValueObject.create(0.05);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(0.6929519121748391);
+ });
+
+ it('Alpha value test', () => {
+ const alpha = NumberValueObject.create(-0.05);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const alpha2 = NumberValueObject.create(1.05);
+ const result2 = testFunction.calculate(alpha2, standardDev, size);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('StandardDev value test', () => {
+ const alpha = NumberValueObject.create(0.05);
+ const standardDev = NumberValueObject.create(-2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Size Value test', () => {
+ const alpha = NumberValueObject.create(0.05);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(0.9);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const alpha = StringValueObject.create('test');
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const alpha = BooleanValueObject.create(true);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const alpha = NullValueObject.create();
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const alpha = ErrorValueObject.create(ErrorType.NAME);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const alpha = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/confidence-norm/index.ts b/packages/engine-formula/src/functions/statistical/confidence-norm/index.ts
new file mode 100644
index 0000000000..7afec78da5
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/confidence-norm/index.ts
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { normalINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ConfidenceNorm extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(alpha: BaseValueObject, standardDev: BaseValueObject, size: BaseValueObject): BaseValueObject {
+ const maxRowLength = Math.max(
+ alpha.isArray() ? (alpha as ArrayValueObject).getRowCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getRowCount() : 1,
+ size.isArray() ? (size as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ alpha.isArray() ? (alpha as ArrayValueObject).getColumnCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getColumnCount() : 1,
+ size.isArray() ? (size as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType.NA));
+ const standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType.NA));
+ const sizeArray = expandArrayValueObject(maxRowLength, maxColumnLength, size, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = alphaArray.mapValue((alphaObject, rowIndex, columnIndex) => {
+ const standardDevObject = standardDevArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const sizeObject = sizeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(alphaObject, standardDevObject, sizeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_alphaObject, _standardDevObject, _sizeObject] = variants as BaseValueObject[];
+
+ const alphaValue = +_alphaObject.getValue();
+ const standardDevValue = +_standardDevObject.getValue();
+ const sizeValue = Math.floor(+_sizeObject.getValue());
+
+ if (alphaValue <= 0 || alphaValue >= 1 || standardDevValue <= 0 || sizeValue < 1) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = Math.abs(normalINV(alphaValue / 2, 0, 1) * standardDevValue / Math.sqrt(sizeValue));
+
+ return NumberValueObject.create(result);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/confidence-t/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/confidence-t/__tests__/index.spec.ts
new file mode 100644
index 0000000000..1bfd8d852e
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/confidence-t/__tests__/index.spec.ts
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ConfidenceT } from '../index';
+
+describe('Test confidenceT function', () => {
+ const testFunction = new ConfidenceT(FUNCTION_NAMES_STATISTICAL.CONFIDENCE_T);
+
+ describe('ConfidenceT', () => {
+ it('Value is normal', () => {
+ const alpha = NumberValueObject.create(0.05);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(0.7104921378216537);
+ });
+
+ it('Alpha value test', () => {
+ const alpha = NumberValueObject.create(-0.05);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const alpha2 = NumberValueObject.create(1.05);
+ const result2 = testFunction.calculate(alpha2, standardDev, size);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('StandardDev value test', () => {
+ const alpha = NumberValueObject.create(0.05);
+ const standardDev = NumberValueObject.create(-2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Size Value test', () => {
+ const alpha = NumberValueObject.create(0.05);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(0.9);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const size2 = NumberValueObject.create(1);
+ const result2 = testFunction.calculate(alpha, standardDev, size2);
+ expect(getObjectValue(result2)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value is normal string', () => {
+ const alpha = StringValueObject.create('test');
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const alpha = BooleanValueObject.create(true);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const alpha = NullValueObject.create();
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const alpha = ErrorValueObject.create(ErrorType.NAME);
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const alpha = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const standardDev = NumberValueObject.create(2.5);
+ const size = NumberValueObject.create(50);
+ const result = testFunction.calculate(alpha, standardDev, size);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/confidence-t/index.ts b/packages/engine-formula/src/functions/statistical/confidence-t/index.ts
new file mode 100644
index 0000000000..9a865fcd0d
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/confidence-t/index.ts
@@ -0,0 +1,83 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { studentTINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ConfidenceT extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(alpha: BaseValueObject, standardDev: BaseValueObject, size: BaseValueObject): BaseValueObject {
+ const maxRowLength = Math.max(
+ alpha.isArray() ? (alpha as ArrayValueObject).getRowCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getRowCount() : 1,
+ size.isArray() ? (size as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ alpha.isArray() ? (alpha as ArrayValueObject).getColumnCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getColumnCount() : 1,
+ size.isArray() ? (size as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType.NA));
+ const standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType.NA));
+ const sizeArray = expandArrayValueObject(maxRowLength, maxColumnLength, size, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = alphaArray.mapValue((alphaObject, rowIndex, columnIndex) => {
+ const standardDevObject = standardDevArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const sizeObject = sizeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(alphaObject, standardDevObject, sizeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_alphaObject, _standardDevObject, _sizeObject] = variants as BaseValueObject[];
+
+ const alphaValue = +_alphaObject.getValue();
+ const standardDevValue = +_standardDevObject.getValue();
+ const sizeValue = Math.floor(+_sizeObject.getValue());
+
+ if (alphaValue <= 0 || alphaValue >= 1 || standardDevValue <= 0 || sizeValue < 1) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ if (sizeValue === 1) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ const result = Math.abs(studentTINV(alphaValue / 2, sizeValue - 1) * standardDevValue / Math.sqrt(sizeValue));
+
+ return NumberValueObject.create(result);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/correl/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/correl/__tests__/index.spec.ts
new file mode 100644
index 0000000000..d0cb8a642d
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/correl/__tests__/index.spec.ts
@@ -0,0 +1,311 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { Correl } from '../index';
+
+describe('Test correl function', () => {
+ const testFunction = new Correl(FUNCTION_NAMES_STATISTICAL.CORREL);
+
+ describe('Correl', () => {
+ it('Value is normal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(0.8355334373537249);
+ });
+
+ it('Value length is equal to 1', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value length is not equal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value is error', () => {
+ const array1 = ErrorValueObject.create(ErrorType.NAME);
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+
+ const array5 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array6 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(array5, array6);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const array7 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array8 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(array7, array8);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null', () => {
+ const array1 = NullValueObject.create();
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = NullValueObject.create();
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is can not calculate', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, null],
+ [11, 'test'],
+ [10, true],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [false, 47.65],
+ [null, 18.44],
+ ['test', 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Result div/0', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 1],
+ [1, 1],
+ [1, 1],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 1],
+ [1, 1],
+ [1, 1],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/correl/index.ts b/packages/engine-formula/src/functions/statistical/correl/index.ts
new file mode 100644
index 0000000000..b302d73df0
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/correl/index.ts
@@ -0,0 +1,128 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { getTwoArrayNumberValues } from '../../../basics/statistical';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Correl extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(array1: BaseValueObject, array2: BaseValueObject): BaseValueObject {
+ const array1RowCount = array1.isArray() ? (array1 as ArrayValueObject).getRowCount() : 1;
+ const array1ColumnCount = array1.isArray() ? (array1 as ArrayValueObject).getColumnCount() : 1;
+
+ const array2RowCount = array2.isArray() ? (array2 as ArrayValueObject).getRowCount() : 1;
+ const array2ColumnCount = array2.isArray() ? (array2 as ArrayValueObject).getColumnCount() : 1;
+
+ let _array1 = array1;
+
+ if (array1.isArray() && array1RowCount === 1 && array1ColumnCount === 1) {
+ _array1 = (array1 as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_array1.isError()) {
+ return _array1;
+ }
+
+ let _array2 = array2;
+
+ if (array2.isArray() && array2RowCount === 1 && array2ColumnCount === 1) {
+ _array2 = (array2 as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_array2.isError()) {
+ return _array2;
+ }
+
+ if (array1RowCount * array1ColumnCount === 1 || array2RowCount * array2ColumnCount === 1) {
+ if (_array1.isNull() || _array2.isNull()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ if (array1RowCount * array1ColumnCount !== array2RowCount * array2ColumnCount) {
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ const {
+ isError,
+ errorObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ } = getTwoArrayNumberValues(
+ array1,
+ array2,
+ array1RowCount * array1ColumnCount,
+ array1ColumnCount,
+ array2ColumnCount
+ );
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ if (noCalculate) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return this._getResult(array1Values, array2Values);
+ }
+
+ private _getResult(array1Values: number[], array2Values: number[]): BaseValueObject {
+ const n = array1Values.length;
+
+ let array1Sum = 0;
+ let array2Sum = 0;
+
+ for (let i = 0; i < n; i++) {
+ array1Sum += array1Values[i];
+ array2Sum += array2Values[i];
+ }
+
+ const array1Mean = array1Sum / n;
+ const array2Mean = array2Sum / n;
+
+ let numerator = 0;
+ let array1DiffSum = 0;
+ let array2DiffSum = 0;
+
+ for (let i = 0; i < n; i++) {
+ const array1Diff = array1Values[i] - array1Mean;
+ const array2Diff = array2Values[i] - array2Mean;
+
+ numerator += array1Diff * array2Diff;
+ array1DiffSum += array1Diff ** 2;
+ array2DiffSum += array2Diff ** 2;
+ }
+
+ const denominator = Math.sqrt(array1DiffSum * array2DiffSum);
+
+ if (denominator === 0) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return NumberValueObject.create(numerator / denominator);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/covariance-p/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/covariance-p/__tests__/index.spec.ts
new file mode 100644
index 0000000000..54780087d5
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/covariance-p/__tests__/index.spec.ts
@@ -0,0 +1,294 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { CovarianceP } from '../index';
+
+describe('Test covarianceP function', () => {
+ const testFunction = new CovarianceP(FUNCTION_NAMES_STATISTICAL.COVARIANCE_P);
+
+ describe('CovarianceP', () => {
+ it('Value is normal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(188.00666666666663);
+ });
+
+ it('Value length is equal to 1', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(0);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ ['test'],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(array1, array3);
+ expect(getObjectValue(result2)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value length is not equal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value is error', () => {
+ const array1 = ErrorValueObject.create(ErrorType.NAME);
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+
+ const array5 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array6 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(array5, array6);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const array7 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array8 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(array7, array8);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null', () => {
+ const array1 = NullValueObject.create();
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = NullValueObject.create();
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is can not calculate', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, null],
+ [11, 'test'],
+ [10, true],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [false, 47.65],
+ [null, 18.44],
+ ['test', 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/covariance-p/index.ts b/packages/engine-formula/src/functions/statistical/covariance-p/index.ts
new file mode 100644
index 0000000000..fa26655e12
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/covariance-p/index.ts
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { getTwoArrayNumberValues } from '../../../basics/statistical';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class CovarianceP extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(array1: BaseValueObject, array2: BaseValueObject): BaseValueObject {
+ const array1RowCount = array1.isArray() ? (array1 as ArrayValueObject).getRowCount() : 1;
+ const array1ColumnCount = array1.isArray() ? (array1 as ArrayValueObject).getColumnCount() : 1;
+
+ const array2RowCount = array2.isArray() ? (array2 as ArrayValueObject).getRowCount() : 1;
+ const array2ColumnCount = array2.isArray() ? (array2 as ArrayValueObject).getColumnCount() : 1;
+
+ let _array1 = array1;
+
+ if (array1.isArray() && array1RowCount === 1 && array1ColumnCount === 1) {
+ _array1 = (array1 as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_array1.isError()) {
+ return _array1;
+ }
+
+ let _array2 = array2;
+
+ if (array2.isArray() && array2RowCount === 1 && array2ColumnCount === 1) {
+ _array2 = (array2 as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_array2.isError()) {
+ return _array2;
+ }
+
+ if (array1RowCount * array1ColumnCount === 1 || array2RowCount * array2ColumnCount === 1) {
+ if (_array1.isNull() || _array2.isNull()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+ }
+
+ if (array1RowCount * array1ColumnCount !== array2RowCount * array2ColumnCount) {
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ const {
+ isError,
+ errorObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ } = getTwoArrayNumberValues(
+ array1,
+ array2,
+ array1RowCount * array1ColumnCount,
+ array1ColumnCount,
+ array2ColumnCount
+ );
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ if (noCalculate) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return this._getResult(array1Values, array2Values);
+ }
+
+ private _getResult(array1Values: number[], array2Values: number[]): BaseValueObject {
+ if (array1Values.length === 0) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ const n = array1Values.length;
+
+ let array1Sum = 0;
+ let array2Sum = 0;
+
+ for (let i = 0; i < n; i++) {
+ array1Sum += array1Values[i];
+ array2Sum += array2Values[i];
+ }
+
+ const array1Mean = array1Sum / n;
+ const array2Mean = array2Sum / n;
+
+ let numerator = 0;
+
+ for (let i = 0; i < n; i++) {
+ const array1Diff = array1Values[i] - array1Mean;
+ const array2Diff = array2Values[i] - array2Mean;
+
+ numerator += array1Diff * array2Diff;
+ }
+
+ return NumberValueObject.create(numerator / n);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/covariance-s/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/covariance-s/__tests__/index.spec.ts
new file mode 100644
index 0000000000..977ec61502
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/covariance-s/__tests__/index.spec.ts
@@ -0,0 +1,280 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { CovarianceS } from '../index';
+
+describe('Test covarianceS function', () => {
+ const testFunction = new CovarianceS(FUNCTION_NAMES_STATISTICAL.COVARIANCE_S);
+
+ describe('CovarianceS', () => {
+ it('Value is normal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(225.60799999999995);
+ });
+
+ it('Value length is equal to 1', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value length is not equal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value is error', () => {
+ const array1 = ErrorValueObject.create(ErrorType.NAME);
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+
+ const array5 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array6 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(array5, array6);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const array7 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array8 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(array7, array8);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null', () => {
+ const array1 = NullValueObject.create();
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = NullValueObject.create();
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is can not calculate', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, null],
+ [11, 'test'],
+ [10, true],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [false, 47.65],
+ [null, 18.44],
+ ['test', 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/covariance-s/index.ts b/packages/engine-formula/src/functions/statistical/covariance-s/index.ts
new file mode 100644
index 0000000000..bd24e24090
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/covariance-s/index.ts
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { getTwoArrayNumberValues } from '../../../basics/statistical';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class CovarianceS extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(array1: BaseValueObject, array2: BaseValueObject): BaseValueObject {
+ const array1RowCount = array1.isArray() ? (array1 as ArrayValueObject).getRowCount() : 1;
+ const array1ColumnCount = array1.isArray() ? (array1 as ArrayValueObject).getColumnCount() : 1;
+
+ const array2RowCount = array2.isArray() ? (array2 as ArrayValueObject).getRowCount() : 1;
+ const array2ColumnCount = array2.isArray() ? (array2 as ArrayValueObject).getColumnCount() : 1;
+
+ let _array1 = array1;
+
+ if (array1.isArray() && array1RowCount === 1 && array1ColumnCount === 1) {
+ _array1 = (array1 as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_array1.isError()) {
+ return _array1;
+ }
+
+ let _array2 = array2;
+
+ if (array2.isArray() && array2RowCount === 1 && array2ColumnCount === 1) {
+ _array2 = (array2 as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_array2.isError()) {
+ return _array2;
+ }
+
+ if (array1RowCount * array1ColumnCount === 1 || array2RowCount * array2ColumnCount === 1) {
+ if (_array1.isNull() || _array2.isNull()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+ }
+
+ if (array1RowCount * array1ColumnCount !== array2RowCount * array2ColumnCount) {
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ const {
+ isError,
+ errorObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ } = getTwoArrayNumberValues(
+ array1,
+ array2,
+ array1RowCount * array1ColumnCount,
+ array1ColumnCount,
+ array2ColumnCount
+ );
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ if (noCalculate) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return this._getResult(array1Values, array2Values);
+ }
+
+ private _getResult(array1Values: number[], array2Values: number[]): BaseValueObject {
+ if (array1Values.length <= 1) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ const n = array1Values.length;
+
+ let array1Sum = 0;
+ let array2Sum = 0;
+
+ for (let i = 0; i < n; i++) {
+ array1Sum += array1Values[i];
+ array2Sum += array2Values[i];
+ }
+
+ const array1Mean = array1Sum / n;
+ const array2Mean = array2Sum / n;
+
+ let numerator = 0;
+
+ for (let i = 0; i < n; i++) {
+ const array1Diff = array1Values[i] - array1Mean;
+ const array2Diff = array2Values[i] - array2Mean;
+
+ numerator += array1Diff * array2Diff;
+ }
+
+ return NumberValueObject.create(numerator / (n - 1));
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/devsq/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/devsq/__tests__/index.spec.ts
new file mode 100644
index 0000000000..8061ec6e47
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/devsq/__tests__/index.spec.ts
@@ -0,0 +1,136 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject, NumberValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { Devsq } from '../index';
+
+describe('Test devsq function', () => {
+ const testFunction = new Devsq(FUNCTION_NAMES_STATISTICAL.DEVSQ);
+
+ describe('Devsq', () => {
+ it('Value is normal', () => {
+ const number1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const number2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(2736.3684000000003);
+ });
+
+ it('Value is error', () => {
+ const number1 = ErrorValueObject.create(ErrorType.NAME);
+ const number2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const number3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(number2, number3);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null or normal string or boolean', () => {
+ const number1 = NullValueObject.create();
+ const number2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 'test'],
+ [true, 18.44],
+ [16.09, false],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const number3 = NumberValueObject.create(1);
+ const result = testFunction.calculate(number1, number2, number3);
+ expect(getObjectValue(result)).toBe(1021.1506000000002);
+ });
+
+ it('Value is can not calculate', () => {
+ const number1 = NullValueObject.create();
+ const number2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [null, null],
+ [null, null],
+ [null, null],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/devsq/index.ts b/packages/engine-formula/src/functions/statistical/devsq/index.ts
new file mode 100644
index 0000000000..d79df05587
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/devsq/index.ts
@@ -0,0 +1,116 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { isRealNum } from '@univerjs/core';
+import { ErrorType } from '../../../basics/error-type';
+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NullValueObject, NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Devsq extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 255;
+
+ override calculate(...variants: BaseValueObject[]): BaseValueObject {
+ const values: number[] = [];
+ let sum = 0;
+ let noCalculate = true;
+
+ for (let i = 0; i < variants.length; i++) {
+ const variant = variants[i];
+
+ if (variant.isArray()) {
+ let isError = false;
+ let errorObject = ErrorValueObject.create(ErrorType.VALUE);
+
+ (variant as ArrayValueObject).iterator((valueObject) => {
+ const _valueObject = this._handleSingleObject(valueObject as BaseValueObject);
+
+ if (_valueObject.isError()) {
+ isError = true;
+ errorObject = _valueObject as ErrorValueObject;
+ return false;
+ }
+
+ if (_valueObject.isNull()) {
+ return true;
+ }
+
+ const value = (_valueObject as NumberValueObject).getValue();
+
+ values.push(value);
+ sum += value;
+ noCalculate = false;
+ });
+
+ if (isError) {
+ return errorObject;
+ }
+ } else {
+ const _variant = this._handleSingleObject(variant);
+
+ if (_variant.isError()) {
+ return _variant;
+ }
+
+ if (_variant.isNull()) {
+ continue;
+ }
+
+ const value = (_variant as NumberValueObject).getValue();
+
+ values.push(value);
+ sum += value;
+ noCalculate = false;
+ }
+ }
+
+ if (noCalculate) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const mean = sum / values.length;
+
+ let result = 0;
+
+ for (let i = 0; i < values.length; i++) {
+ result += (values[i] - mean) ** 2;
+ }
+
+ return NumberValueObject.create(result);
+ }
+
+ private _handleSingleObject(variant: BaseValueObject): BaseValueObject {
+ if (variant.isError()) {
+ return variant;
+ }
+
+ if (variant.isNull() || variant.isBoolean()) {
+ return NullValueObject.create();
+ }
+
+ const value = variant.getValue();
+
+ if (!isRealNum(value)) {
+ return NullValueObject.create();
+ }
+
+ return NumberValueObject.create(+value);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/expon-dist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/expon-dist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..de2a13b44d
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/expon-dist/__tests__/index.spec.ts
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { ExponDist } from '../index';
+
+describe('Test exponDist function', () => {
+ const testFunction = new ExponDist(FUNCTION_NAMES_STATISTICAL.EXPON_DIST);
+
+ describe('ExponDist', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(0.5);
+ const lambda = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toBe(0.3934693402873666);
+ });
+
+ it('Lambda value test', () => {
+ const x = NumberValueObject.create(0.5);
+ const lambda = NumberValueObject.create(0);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom2 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(x, degFreedom2, cumulative);
+ expect(getObjectValue(result2)).toBe(1);
+ });
+
+ it('Cumulative value test', () => {
+ const x = NumberValueObject.create(0.5);
+ const lambda = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(false);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toBe(0.6065306597126334);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const lambda = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const lambda = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toBe(0.6321205588285577);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const lambda = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const lambda = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const lambda = NumberValueObject.create(1);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, lambda, cumulative);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.6321205588285577, ErrorType.VALUE, 0.7077074223191406, 0.6321205588285577, 0, 0],
+ [0, 1, 0.9036723617695069, ErrorType.VALUE, ErrorType.NUM, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/expon-dist/index.ts b/packages/engine-formula/src/functions/statistical/expon-dist/index.ts
new file mode 100644
index 0000000000..a353429037
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/expon-dist/index.ts
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { exponentialCDF, exponentialPDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class ExponDist extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(
+ x: BaseValueObject,
+ lambda: BaseValueObject,
+ cumulative: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ lambda.isArray() ? (lambda as ArrayValueObject).getRowCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ lambda.isArray() ? (lambda as ArrayValueObject).getColumnCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const lambdaArray = expandArrayValueObject(maxRowLength, maxColumnLength, lambda, ErrorValueObject.create(ErrorType.NA));
+ const cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const lambdaObject = lambdaArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, lambdaObject, cumulativeObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ lambdaObject: BaseValueObject,
+ cumulativeObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, lambdaObject, cumulativeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _lambdaObject, _cumulativeObject] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const lambdaValue = +_lambdaObject.getValue();
+ const cumulativeValue = +_cumulativeObject.getValue();
+
+ if (xValue < 0 || lambdaValue <= 0) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result;
+
+ if (cumulativeValue) {
+ result = exponentialCDF(xValue, lambdaValue);
+ } else {
+ result = exponentialPDF(xValue, lambdaValue);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/f-dist-rt/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/f-dist-rt/__tests__/index.spec.ts
new file mode 100644
index 0000000000..029358b9c8
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-dist-rt/__tests__/index.spec.ts
@@ -0,0 +1,105 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { FDistRt } from '../index';
+
+describe('Test fDistRt function', () => {
+ const testFunction = new FDistRt(FUNCTION_NAMES_STATISTICAL.F_DIST_RT);
+
+ describe('FDistRt', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(15.2069);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(0.009999956997237325);
+ });
+
+ it('DegFreedom value test', () => {
+ const x = NumberValueObject.create(15.2069);
+ const degFreedom1 = NumberValueObject.create(0);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom3 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(x, degFreedom3, degFreedom2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(0.5248000000000005);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.5248000000000005, ErrorType.VALUE, 0.43966913698600196, 0.5248000000000005, 1, 1],
+ [1, 0.0002608285356223705, 0.2150262771598519, ErrorType.VALUE, ErrorType.NUM, 1],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/f-dist-rt/index.ts b/packages/engine-formula/src/functions/statistical/f-dist-rt/index.ts
new file mode 100644
index 0000000000..ae93830a96
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-dist-rt/index.ts
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { centralFCDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class FDistRt extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(
+ x: BaseValueObject,
+ degFreedom1: BaseValueObject,
+ degFreedom2: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getRowCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getColumnCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex) as BaseValueObject;
+ const degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, degFreedom1Object, degFreedom2Object);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ degFreedom1Object: BaseValueObject,
+ degFreedom2Object: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedom1Object, degFreedom2Object);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _degFreedom1Object, _degFreedom2Object] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const degFreedom1Value = Math.floor(+_degFreedom1Object.getValue());
+ const degFreedom2Value = Math.floor(+_degFreedom2Object.getValue());
+
+ if (xValue < 0 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = 1 - centralFCDF(xValue, degFreedom1Value, degFreedom2Value);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/f-dist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/f-dist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..76bf2cc67b
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-dist/__tests__/index.spec.ts
@@ -0,0 +1,133 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { FDist } from '../index';
+
+describe('Test fDist function', () => {
+ const testFunction = new FDist(FUNCTION_NAMES_STATISTICAL.F_DIST);
+
+ describe('FDist', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(15.2069);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toBe(0.9900000430027627);
+ });
+
+ it('DegFreedom value test', () => {
+ const x = NumberValueObject.create(15.2069);
+ const degFreedom1 = NumberValueObject.create(0);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom3 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(x, degFreedom3, degFreedom2, cumulative);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Cumulative value test', () => {
+ const x = NumberValueObject.create(15.2069);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(false);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toBe(0.0012237917087831733);
+
+ const x2 = NumberValueObject.create(0);
+ const degFreedom3 = NumberValueObject.create(1);
+ const result2 = testFunction.calculate(x2, degFreedom3, degFreedom3, cumulative);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+
+ const degFreedom4 = NumberValueObject.create(2);
+ const result3 = testFunction.calculate(x2, degFreedom4, degFreedom1, cumulative);
+ expect(getObjectValue(result3)).toBe(1);
+
+ const result4 = testFunction.calculate(x, degFreedom4, degFreedom4, cumulative);
+ expect(getObjectValue(result4)).toBe(0.0038071509376540248);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toBe(0.4751999999999995);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, degFreedom1, degFreedom2, cumulative);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.4751999999999995, ErrorType.VALUE, 0.560330863013998, 0.4751999999999995, 0, 0],
+ [0, 0.9997391714643776, 0.7849737228401481, ErrorType.VALUE, ErrorType.NUM, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/f-dist/index.ts b/packages/engine-formula/src/functions/statistical/f-dist/index.ts
new file mode 100644
index 0000000000..8405812653
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-dist/index.ts
@@ -0,0 +1,108 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { centralFCDF, centralFPDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class FDist extends BaseFunction {
+ override minParams = 4;
+
+ override maxParams = 4;
+
+ override calculate(
+ x: BaseValueObject,
+ degFreedom1: BaseValueObject,
+ degFreedom2: BaseValueObject,
+ cumulative: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getRowCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getRowCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getColumnCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getColumnCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType.NA));
+ const cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex) as BaseValueObject;
+ const degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex) as BaseValueObject;
+ const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, degFreedom1Object, degFreedom2Object, cumulativeObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ degFreedom1Object: BaseValueObject,
+ degFreedom2Object: BaseValueObject,
+ cumulativeObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedom1Object, degFreedom2Object, cumulativeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _degFreedom1Object, _degFreedom2Object, _cumulativeObject] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const degFreedom1Value = Math.floor(+_degFreedom1Object.getValue());
+ const degFreedom2Value = Math.floor(+_degFreedom2Object.getValue());
+ const cumulativeValue = +_cumulativeObject.getValue();
+
+ if (xValue < 0 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result;
+
+ if (cumulativeValue) {
+ result = centralFCDF(xValue, degFreedom1Value, degFreedom2Value);
+ } else {
+ result = centralFPDF(xValue, degFreedom1Value, degFreedom2Value);
+ }
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/f-inv-rt/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/f-inv-rt/__tests__/index.spec.ts
new file mode 100644
index 0000000000..d657f22c48
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-inv-rt/__tests__/index.spec.ts
@@ -0,0 +1,105 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { FInvRt } from '../index';
+
+describe('Test fInvRt function', () => {
+ const testFunction = new FInvRt(FUNCTION_NAMES_STATISTICAL.F_INV_RT);
+
+ describe('FInvRt', () => {
+ it('Value is normal', () => {
+ const probability = NumberValueObject.create(0.01);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(15.206864861157555);
+ });
+
+ it('DegFreedom value test', () => {
+ const probability = NumberValueObject.create(0.01);
+ const degFreedom1 = NumberValueObject.create(0);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom3 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(probability, degFreedom3, degFreedom2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const probability = StringValueObject.create('test');
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const probability = BooleanValueObject.create(true);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is null', () => {
+ const probability = NullValueObject.create();
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const probability = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const probability = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0, ErrorType.VALUE, ErrorType.NUM, 0, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/f-inv-rt/index.ts b/packages/engine-formula/src/functions/statistical/f-inv-rt/index.ts
new file mode 100644
index 0000000000..e56550bbf8
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-inv-rt/index.ts
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { centralFINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class FInvRt extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(
+ probability: BaseValueObject,
+ degFreedom1: BaseValueObject,
+ degFreedom2: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getRowCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getRowCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getColumnCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getColumnCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
+ const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex) as BaseValueObject;
+ const degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(probabilityObject, degFreedom1Object, degFreedom2Object);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ probabilityObject: BaseValueObject,
+ degFreedom1Object: BaseValueObject,
+ degFreedom2Object: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedom1Object, degFreedom2Object);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_probabilityObject, _degFreedom1Object, _degFreedom2Object] = variants as BaseValueObject[];
+
+ const probabilityValue = +_probabilityObject.getValue();
+ const degFreedom1Value = Math.floor(+_degFreedom1Object.getValue());
+ const degFreedom2Value = Math.floor(+_degFreedom2Object.getValue());
+
+ if (probabilityValue < 0 || probabilityValue > 1 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = centralFINV(1 - probabilityValue, degFreedom1Value, degFreedom2Value);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/f-inv/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/f-inv/__tests__/index.spec.ts
new file mode 100644
index 0000000000..810c18c5e0
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-inv/__tests__/index.spec.ts
@@ -0,0 +1,105 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { FInv } from '../index';
+
+describe('Test fInv function', () => {
+ const testFunction = new FInv(FUNCTION_NAMES_STATISTICAL.F_INV);
+
+ describe('FInv', () => {
+ it('Value is normal', () => {
+ const probability = NumberValueObject.create(0.01);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(0.10930991412457851);
+ });
+
+ it('DegFreedom value test', () => {
+ const probability = NumberValueObject.create(0.01);
+ const degFreedom1 = NumberValueObject.create(0);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const degFreedom3 = NumberValueObject.create(10 ** 10 + 1);
+ const result2 = testFunction.calculate(probability, degFreedom3, degFreedom2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const probability = StringValueObject.create('test');
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const probability = BooleanValueObject.create(true);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const probability = NullValueObject.create();
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const probability = ErrorValueObject.create(ErrorType.NAME);
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const probability = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const degFreedom1 = NumberValueObject.create(6);
+ const degFreedom2 = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, degFreedom1, degFreedom2);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, 0, 0],
+ [0, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/f-inv/index.ts b/packages/engine-formula/src/functions/statistical/f-inv/index.ts
new file mode 100644
index 0000000000..39ef45296d
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-inv/index.ts
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { centralFINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class FInv extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(
+ probability: BaseValueObject,
+ degFreedom1: BaseValueObject,
+ degFreedom2: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getRowCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getRowCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getColumnCount() : 1,
+ degFreedom1.isArray() ? (degFreedom1 as ArrayValueObject).getColumnCount() : 1,
+ degFreedom2.isArray() ? (degFreedom2 as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType.NA));
+ const degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
+ const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex) as BaseValueObject;
+ const degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(probabilityObject, degFreedom1Object, degFreedom2Object);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ probabilityObject: BaseValueObject,
+ degFreedom1Object: BaseValueObject,
+ degFreedom2Object: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedom1Object, degFreedom2Object);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_probabilityObject, _degFreedom1Object, _degFreedom2Object] = variants as BaseValueObject[];
+
+ const probabilityValue = +_probabilityObject.getValue();
+ const degFreedom1Value = Math.floor(+_degFreedom1Object.getValue());
+ const degFreedom2Value = Math.floor(+_degFreedom2Object.getValue());
+
+ if (probabilityValue < 0 || probabilityValue > 1 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = centralFINV(probabilityValue, degFreedom1Value, degFreedom2Value);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/f-test/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/f-test/__tests__/index.spec.ts
new file mode 100644
index 0000000000..37f34d0003
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-test/__tests__/index.spec.ts
@@ -0,0 +1,338 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { FTest } from '../index';
+
+describe('Test fTest function', () => {
+ const testFunction = new FTest(FUNCTION_NAMES_STATISTICAL.F_TEST);
+
+ describe('FTest', () => {
+ it('Value is normal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(0.7283721822078002);
+ });
+
+ it('Value length is equal to 1', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value length is not equal', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(0.5601137808756675);
+ });
+
+ it('Value is error', () => {
+ const array1 = ErrorValueObject.create(ErrorType.NAME);
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+
+ const array5 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array6 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(array5, array6);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const array7 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array8 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(array7, array8);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null', () => {
+ const array1 = NullValueObject.create();
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const array3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array4 = NullValueObject.create();
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is can not calculate', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, null],
+ [false, 'test'],
+ [null, true],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [false, 47.65],
+ [null, 18.44],
+ ['test', 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Calculate result > 1', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [6, 7, 9, 15, 21],
+ ]),
+ rowCount: 1,
+ columnCount: 5,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [20, 28, 31, 38, 40],
+ ]),
+ rowCount: 1,
+ columnCount: 5,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(0.6483178467861754);
+ });
+
+ it('Array2Variance === 0', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ [2],
+ [1],
+ ]),
+ rowCount: 3,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ [1],
+ [1],
+ ]),
+ rowCount: 3,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/f-test/index.ts b/packages/engine-formula/src/functions/statistical/f-test/index.ts
new file mode 100644
index 0000000000..3f89cf12d7
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/f-test/index.ts
@@ -0,0 +1,166 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { isRealNum } from '@univerjs/core';
+import { ErrorType } from '../../../basics/error-type';
+import { centralFCDF } from '../../../basics/statistical';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class FTest extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(array1: BaseValueObject, array2: BaseValueObject): BaseValueObject {
+ const {
+ isError: isError_array1,
+ errorObject: errorObject_array1,
+ variance: variance_array1,
+ ns1: ns1_array1,
+ } = this._getValues(array1);
+
+ if (isError_array1) {
+ return errorObject_array1 as ErrorValueObject;
+ }
+
+ const {
+ isError: isError_array2,
+ errorObject: errorObject_array2,
+ variance: variance_array2,
+ ns1: ns1_array2,
+ } = this._getValues(array2);
+
+ if (isError_array2) {
+ return errorObject_array2 as ErrorValueObject;
+ }
+
+ let result = 2 * (1 - centralFCDF(variance_array1 / variance_array2, ns1_array1, ns1_array2));
+
+ if (result > 1) {
+ result = 2 - result;
+ }
+
+ return NumberValueObject.create(result);
+ }
+
+ // eslint-disable-next-line
+ private _getValues(array: BaseValueObject) {
+ let variance = 0;
+ let ns1 = 0;
+
+ const arrayRowCount = array.isArray() ? (array as ArrayValueObject).getRowCount() : 1;
+ const arrayColumnCount = array.isArray() ? (array as ArrayValueObject).getColumnCount() : 1;
+
+ if (arrayRowCount === 1 && arrayColumnCount === 1) {
+ const _array = array.isArray() ? (array as ArrayValueObject).get(0, 0) as BaseValueObject : array;
+
+ if (_array.isError()) {
+ return {
+ isError: true,
+ errorObject: _array,
+ variance,
+ ns1,
+ };
+ }
+
+ if (_array.isNull()) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.VALUE),
+ variance,
+ ns1,
+ };
+ }
+
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.DIV_BY_ZERO),
+ variance,
+ ns1,
+ };
+ }
+
+ const values = [];
+ let sum = 0;
+
+ for (let r = 0; r < arrayRowCount; r++) {
+ for (let c = 0; c < arrayColumnCount; c++) {
+ const valueObject = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
+
+ if (valueObject.isError()) {
+ return {
+ isError: true,
+ errorObject: valueObject,
+ variance,
+ ns1,
+ };
+ }
+
+ if (valueObject.isNull() || valueObject.isBoolean()) {
+ continue;
+ }
+
+ const value = valueObject.getValue();
+
+ if (!isRealNum(value)) {
+ continue;
+ }
+
+ values.push(+value);
+ sum += +value;
+ }
+ }
+
+ if (values.length <= 1) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.DIV_BY_ZERO),
+ variance,
+ ns1,
+ };
+ }
+
+ const mean = sum / values.length;
+
+ let sumSquares = 0;
+
+ for (let i = 0; i < values.length; i++) {
+ sumSquares += (values[i] - mean) ** 2;
+ }
+
+ ns1 = values.length - 1;
+ variance = sumSquares / ns1;
+
+ if (variance === 0) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.DIV_BY_ZERO),
+ variance,
+ ns1,
+ };
+ }
+
+ return {
+ isError: false,
+ errorObject: null,
+ variance,
+ ns1,
+ };
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/fisher/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/fisher/__tests__/index.spec.ts
new file mode 100644
index 0000000000..b3632f22a6
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/fisher/__tests__/index.spec.ts
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { Fisher } from '../index';
+
+describe('Test fisher function', () => {
+ const testFunction = new Fisher(FUNCTION_NAMES_STATISTICAL.FISHER);
+
+ describe('Fisher', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(0.9729550745276566);
+ });
+
+ it('Value is number string', () => {
+ const x = StringValueObject.create('0.5');
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(0.5493061443340548);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, 0, 0],
+ [0, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/fisher/index.ts b/packages/engine-formula/src/functions/statistical/fisher/index.ts
new file mode 100644
index 0000000000..60aa2d5889
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/fisher/index.ts
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Fisher extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(x: BaseValueObject): BaseValueObject {
+ if (x.isArray()) {
+ return (x as ArrayValueObject).mapValue((xObject) => this._handleSingleObject(xObject as BaseValueObject));
+ }
+
+ return this._handleSingleObject(x);
+ }
+
+ private _handleSingleObject(x: BaseValueObject): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(x);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [xObject] = variants as BaseValueObject[];
+
+ const xValue = (xObject as NumberValueObject).getValue();
+
+ if (xValue <= -1 || xValue >= 1) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = Math.log((1 + xValue) / (1 - xValue)) / 2;
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/fisherinv/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/fisherinv/__tests__/index.spec.ts
new file mode 100644
index 0000000000..8135c4658f
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/fisherinv/__tests__/index.spec.ts
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { Fisherinv } from '../index';
+
+describe('Test fisherinv function', () => {
+ const testFunction = new Fisherinv(FUNCTION_NAMES_STATISTICAL.FISHERINV);
+
+ describe('Fisherinv', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(0.75);
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(0.6351489523872873);
+ });
+
+ it('Value is big number', () => {
+ const x = NumberValueObject.create(9999999.23658);
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is number string', () => {
+ const x = StringValueObject.create('0.5');
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(0.46211715726000974);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(0.7615941559557649);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.7615941559557649, ErrorType.VALUE, 0.8425793256589296, 0.7615941559557649, 0, 0],
+ [0, 1, 0.9816125892654238, ErrorType.VALUE, -0.9950547536867306, 0],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/fisherinv/index.ts b/packages/engine-formula/src/functions/statistical/fisherinv/index.ts
new file mode 100644
index 0000000000..33fa8e3c4f
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/fisherinv/index.ts
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Fisherinv extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(y: BaseValueObject): BaseValueObject {
+ if (y.isArray()) {
+ return (y as ArrayValueObject).mapValue((yObject) => this._handleSingleObject(yObject as BaseValueObject));
+ }
+
+ return this._handleSingleObject(y);
+ }
+
+ private _handleSingleObject(y: BaseValueObject): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(y);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [yObject] = variants as BaseValueObject[];
+
+ const yValue = +yObject.getValue();
+
+ const num = Math.exp(2 * yValue) - 1;
+ const den = Math.exp(2 * yValue) + 1;
+
+ if (!Number.isFinite(num) && num > 0 && !Number.isFinite(den) && den > 0) {
+ return NumberValueObject.create(1);
+ }
+
+ return NumberValueObject.create(num / den);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/forecast/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/forecast/__tests__/index.spec.ts
new file mode 100644
index 0000000000..5effddbe63
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/forecast/__tests__/index.spec.ts
@@ -0,0 +1,364 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject, NumberValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { Forecast } from '../index';
+
+describe('Test forecast function', () => {
+ const testFunction = new Forecast(FUNCTION_NAMES_STATISTICAL.FORECAST);
+
+ describe('Forecast', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(30);
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(29.952035314302105);
+ });
+
+ it('X value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1.4156939427151058, ErrorType.VALUE, 1.6420166501449338, 1.4156939427151058, 0.43168217128107145, 0.43168217128107145],
+ [0.43168217128107145, 98.83285931468451, 2.734269716436712, ErrorType.VALUE, -2.5203531430210315, ErrorType.NAME],
+ ]);
+ });
+
+ it('Value length is equal to 1', () => {
+ const x = NumberValueObject.create(30);
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value length is not equal', () => {
+ const x = NumberValueObject.create(30);
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value is error', () => {
+ const x = NumberValueObject.create(30);
+ const knownYs = ErrorValueObject.create(ErrorType.NAME);
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const knownYs2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs2 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(x, knownYs2, knownXs2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+
+ const knownYs3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(x, knownYs3, knownXs3);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const knownYs4 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs4 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(x, knownYs4, knownXs4);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null', () => {
+ const x = NumberValueObject.create(30);
+ const knownYs = NullValueObject.create();
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const knownYs2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs2 = NullValueObject.create();
+ const result2 = testFunction.calculate(x, knownYs2, knownXs2);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is can not calculate', () => {
+ const x = NumberValueObject.create(30);
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, null],
+ [11, 'test'],
+ [10, true],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [false, 47.65],
+ [null, 18.44],
+ ['test', 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Array2Variance === 0', () => {
+ const x = NumberValueObject.create(30);
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ [2],
+ [1],
+ ]),
+ rowCount: 3,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ [1],
+ [1],
+ ]),
+ rowCount: 3,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/forecast/index.ts b/packages/engine-formula/src/functions/statistical/forecast/index.ts
new file mode 100644
index 0000000000..73476e9826
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/forecast/index.ts
@@ -0,0 +1,130 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { forecastLinear, getTwoArrayNumberValues } from '../../../basics/statistical';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Forecast extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(x: BaseValueObject, knownYs: BaseValueObject, knownXs: BaseValueObject): BaseValueObject {
+ const knownYsRowCount = knownYs.isArray() ? (knownYs as ArrayValueObject).getRowCount() : 1;
+ const knownYsColumnCount = knownYs.isArray() ? (knownYs as ArrayValueObject).getColumnCount() : 1;
+
+ const knownXsRowCount = knownXs.isArray() ? (knownXs as ArrayValueObject).getRowCount() : 1;
+ const knownXsColumnCount = knownXs.isArray() ? (knownXs as ArrayValueObject).getColumnCount() : 1;
+
+ let _knownYs = knownYs;
+
+ if (knownYs.isArray() && knownYsRowCount === 1 && knownYsColumnCount === 1) {
+ _knownYs = (knownYs as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ let _knownXs = knownXs;
+
+ if (knownXs.isArray() && knownXsRowCount === 1 && knownXsColumnCount === 1) {
+ _knownXs = (knownXs as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (x.isArray()) {
+ return (x as ArrayValueObject).mapValue(
+ (xObject) => this._handleSignleObject(xObject, _knownYs, _knownXs, knownYsRowCount, knownYsColumnCount, knownXsRowCount, knownXsColumnCount)
+ );
+ }
+
+ return this._handleSignleObject(x, _knownYs, _knownXs, knownYsRowCount, knownYsColumnCount, knownXsRowCount, knownXsColumnCount);
+ }
+
+ private _handleSignleObject(
+ x: BaseValueObject,
+ knownYs: BaseValueObject,
+ knownXs: BaseValueObject,
+ knownYsRowCount: number,
+ knownYsColumnCount: number,
+ knownXsRowCount: number,
+ knownXsColumnCount: number
+ ): BaseValueObject {
+ if (x.isError()) {
+ return x;
+ }
+
+ if (knownYs.isError()) {
+ return knownYs;
+ }
+
+ if (knownXs.isError()) {
+ return knownXs;
+ }
+
+ let _x = x;
+
+ if (x.isString()) {
+ _x = x.convertToNumberObjectValue();
+ }
+
+ if (_x.isError()) {
+ return _x;
+ }
+
+ const xValue = +_x.getValue();
+
+ if (knownYsRowCount * knownYsColumnCount === 1 || knownXsRowCount * knownXsColumnCount === 1) {
+ if (knownYs.isNull() || knownXs.isNull()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+ }
+
+ if (knownYsRowCount * knownYsColumnCount !== knownXsRowCount * knownXsColumnCount) {
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ const {
+ isError,
+ errorObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ } = getTwoArrayNumberValues(
+ knownYs,
+ knownXs,
+ knownYsRowCount * knownYsColumnCount,
+ knownYsColumnCount,
+ knownXsColumnCount
+ );
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ if (noCalculate) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ const result = forecastLinear(xValue, array1Values, array2Values);
+
+ if (!Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/function-map.ts b/packages/engine-formula/src/functions/statistical/function-map.ts
index c6d77c6977..89d4377899 100644
--- a/packages/engine-formula/src/functions/statistical/function-map.ts
+++ b/packages/engine-formula/src/functions/statistical/function-map.ts
@@ -14,23 +14,53 @@
* limitations under the License.
*/
-import { FUNCTION_NAMES_STATISTICAL } from './function-names';
import { Avedev } from './avedev';
import { Average } from './average';
import { Averagea } from './averagea';
import { Averageif } from './averageif';
import { Averageifs } from './averageifs';
+import { BetaDist } from './beta-dist';
+import { BetaInv } from './beta-inv';
+import { BinomDist } from './binom-dist';
+import { BinomDistRange } from './binom-dist-range';
+import { BinomInv } from './binom-inv';
+import { ChisqDist } from './chisq-dist';
+import { ChisqDistRt } from './chisq-dist-rt';
+import { ChisqInv } from './chisq-inv';
+import { ChisqInvRt } from './chisq-inv-rt';
+import { ChisqTest } from './chisq-test';
+import { ConfidenceNorm } from './confidence-norm';
+import { ConfidenceT } from './confidence-t';
+import { Correl } from './correl';
import { Count } from './count';
import { Counta } from './counta';
import { Countblank } from './countblank';
import { Countif } from './countif';
import { Countifs } from './countifs';
+import { CovarianceP } from './covariance-p';
+import { CovarianceS } from './covariance-s';
+import { Devsq } from './devsq';
+import { ExponDist } from './expon-dist';
+import { FDist } from './f-dist';
+import { FDistRt } from './f-dist-rt';
+import { FInv } from './f-inv';
+import { FInvRt } from './f-inv-rt';
+import { FTest } from './f-test';
+import { Fisher } from './fisher';
+import { Fisherinv } from './fisherinv';
+import { Forecast } from './forecast';
+import { FUNCTION_NAMES_STATISTICAL } from './function-names';
+import { Intercept } from './intercept';
import { Max } from './max';
import { Maxa } from './maxa';
import { Maxifs } from './maxifs';
import { Min } from './min';
import { Mina } from './mina';
import { Minifs } from './minifs';
+import { NormDist } from './norm-dist';
+import { NormInv } from './norm-inv';
+import { NormSDist } from './norm-s-dist';
+import { NormSInv } from './norm-s-inv';
import { RankAvg } from './rank-avg';
import { RankEq } from './rank-eq';
import { StdevP } from './stdev-p';
@@ -48,17 +78,48 @@ export const functionStatistical = [
[Averagea, FUNCTION_NAMES_STATISTICAL.AVERAGEA],
[Averageif, FUNCTION_NAMES_STATISTICAL.AVERAGEIF],
[Averageifs, FUNCTION_NAMES_STATISTICAL.AVERAGEIFS],
+ [BetaDist, FUNCTION_NAMES_STATISTICAL.BETA_DIST],
+ [BetaInv, FUNCTION_NAMES_STATISTICAL.BETA_INV],
+ [BinomDist, FUNCTION_NAMES_STATISTICAL.BINOM_DIST],
+ [BinomDistRange, FUNCTION_NAMES_STATISTICAL.BINOM_DIST_RANGE],
+ [BinomInv, FUNCTION_NAMES_STATISTICAL.BINOM_INV],
+ [ChisqDist, FUNCTION_NAMES_STATISTICAL.CHISQ_DIST],
+ [ChisqDistRt, FUNCTION_NAMES_STATISTICAL.CHISQ_DIST_RT],
+ [ChisqInv, FUNCTION_NAMES_STATISTICAL.CHISQ_INV],
+ [ChisqInvRt, FUNCTION_NAMES_STATISTICAL.CHISQ_INV_RT],
+ [ChisqTest, FUNCTION_NAMES_STATISTICAL.CHISQ_TEST],
+ [ConfidenceNorm, FUNCTION_NAMES_STATISTICAL.CONFIDENCE_NORM],
+ [ConfidenceT, FUNCTION_NAMES_STATISTICAL.CONFIDENCE_T],
+ [Correl, FUNCTION_NAMES_STATISTICAL.CORREL],
[Count, FUNCTION_NAMES_STATISTICAL.COUNT],
[Counta, FUNCTION_NAMES_STATISTICAL.COUNTA],
[Countblank, FUNCTION_NAMES_STATISTICAL.COUNTBLANK],
[Countif, FUNCTION_NAMES_STATISTICAL.COUNTIF],
[Countifs, FUNCTION_NAMES_STATISTICAL.COUNTIFS],
+ [CovarianceP, FUNCTION_NAMES_STATISTICAL.COVARIANCE_P],
+ [CovarianceS, FUNCTION_NAMES_STATISTICAL.COVARIANCE_S],
+ [Devsq, FUNCTION_NAMES_STATISTICAL.DEVSQ],
+ [ExponDist, FUNCTION_NAMES_STATISTICAL.EXPON_DIST],
+ [FDist, FUNCTION_NAMES_STATISTICAL.F_DIST],
+ [FDistRt, FUNCTION_NAMES_STATISTICAL.F_DIST_RT],
+ [FInv, FUNCTION_NAMES_STATISTICAL.F_INV],
+ [FInvRt, FUNCTION_NAMES_STATISTICAL.F_INV_RT],
+ [FTest, FUNCTION_NAMES_STATISTICAL.F_TEST],
+ [Fisher, FUNCTION_NAMES_STATISTICAL.FISHER],
+ [Fisherinv, FUNCTION_NAMES_STATISTICAL.FISHERINV],
+ [Forecast, FUNCTION_NAMES_STATISTICAL.FORECAST],
+ [Forecast, FUNCTION_NAMES_STATISTICAL.FORECAST_LINEAR],
+ [Intercept, FUNCTION_NAMES_STATISTICAL.INTERCEPT],
[Max, FUNCTION_NAMES_STATISTICAL.MAX],
[Maxa, FUNCTION_NAMES_STATISTICAL.MAXA],
[Maxifs, FUNCTION_NAMES_STATISTICAL.MAXIFS],
[Min, FUNCTION_NAMES_STATISTICAL.MIN],
[Mina, FUNCTION_NAMES_STATISTICAL.MINA],
[Minifs, FUNCTION_NAMES_STATISTICAL.MINIFS],
+ [NormDist, FUNCTION_NAMES_STATISTICAL.NORM_DIST],
+ [NormInv, FUNCTION_NAMES_STATISTICAL.NORM_INV],
+ [NormSDist, FUNCTION_NAMES_STATISTICAL.NORM_S_DIST],
+ [NormSInv, FUNCTION_NAMES_STATISTICAL.NORM_S_INV],
[RankAvg, FUNCTION_NAMES_STATISTICAL.RANK_AVG],
[RankEq, FUNCTION_NAMES_STATISTICAL.RANK_EQ],
[StdevP, FUNCTION_NAMES_STATISTICAL.STDEV_P],
diff --git a/packages/engine-formula/src/functions/statistical/intercept/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/intercept/__tests__/index.spec.ts
new file mode 100644
index 0000000000..f49853bb05
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/intercept/__tests__/index.spec.ts
@@ -0,0 +1,311 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { NullValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { Intercept } from '../index';
+
+describe('Test intercept function', () => {
+ const testFunction = new Intercept(FUNCTION_NAMES_STATISTICAL.INTERCEPT);
+
+ describe('Intercept', () => {
+ it('Value is normal', () => {
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(0.43168217128107145);
+ });
+
+ it('Value length is equal to 1', () => {
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value length is not equal', () => {
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value is error', () => {
+ const knownYs = ErrorValueObject.create(ErrorType.NAME);
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const knownYs2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs2 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(knownYs2, knownXs2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+
+ const knownYs3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(knownYs3, knownXs3);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const knownYs4 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs4 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [ErrorType.NAME, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(knownYs4, knownXs4);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is null', () => {
+ const knownYs = NullValueObject.create();
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [45.35, 47.65],
+ [17.56, 18.44],
+ [16.09, 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const knownYs2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, 35],
+ [11, 25],
+ [10, 23],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs2 = NullValueObject.create();
+ const result2 = testFunction.calculate(knownYs2, knownXs2);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is can not calculate', () => {
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [58, null],
+ [11, 'test'],
+ [10, true],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [false, 47.65],
+ [null, 18.44],
+ ['test', 16.91],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Array2Variance === 0', () => {
+ const knownYs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ [2],
+ [1],
+ ]),
+ rowCount: 3,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const knownXs = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ [1],
+ [1],
+ ]),
+ rowCount: 3,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(knownYs, knownXs);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/intercept/index.ts b/packages/engine-formula/src/functions/statistical/intercept/index.ts
new file mode 100644
index 0000000000..793852a7b3
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/intercept/index.ts
@@ -0,0 +1,102 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { forecastLinear, getTwoArrayNumberValues } from '../../../basics/statistical';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Intercept extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(knownYs: BaseValueObject, knownXs: BaseValueObject): BaseValueObject {
+ const knownYsRowCount = knownYs.isArray() ? (knownYs as ArrayValueObject).getRowCount() : 1;
+ const knownYsColumnCount = knownYs.isArray() ? (knownYs as ArrayValueObject).getColumnCount() : 1;
+
+ const knownXsRowCount = knownXs.isArray() ? (knownXs as ArrayValueObject).getRowCount() : 1;
+ const knownXsColumnCount = knownXs.isArray() ? (knownXs as ArrayValueObject).getColumnCount() : 1;
+
+ let _knownYs = knownYs;
+
+ if (knownYs.isArray() && knownYsRowCount === 1 && knownYsColumnCount === 1) {
+ _knownYs = (knownYs as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_knownYs.isError()) {
+ return _knownYs;
+ }
+
+ let _knownXs = knownXs;
+
+ if (knownXs.isArray() && knownXsRowCount === 1 && knownXsColumnCount === 1) {
+ _knownXs = (knownXs as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_knownXs.isError()) {
+ return _knownXs;
+ }
+
+ if (knownYsRowCount * knownYsColumnCount === 1 || knownXsRowCount * knownXsColumnCount === 1) {
+ if (knownYs.isNull() || knownXs.isNull()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ if (knownYsRowCount * knownYsColumnCount !== knownXsRowCount * knownXsColumnCount) {
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ const {
+ isError,
+ errorObject,
+ array1Values,
+ array2Values,
+ noCalculate,
+ } = getTwoArrayNumberValues(
+ knownYs,
+ knownXs,
+ knownYsRowCount * knownYsColumnCount,
+ knownYsColumnCount,
+ knownXsColumnCount
+ );
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ if (noCalculate) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return this._getResult(array1Values, array2Values);
+ }
+
+ private _getResult(knownYs: number[], knownXs: number[]): BaseValueObject {
+ const result = forecastLinear(0, knownYs, knownXs);
+
+ if (!Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/norm-dist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/norm-dist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..8fbac21f56
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-dist/__tests__/index.spec.ts
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { NormDist } from '../index';
+
+describe('Test normDist function', () => {
+ const testFunction = new NormDist(FUNCTION_NAMES_STATISTICAL.NORM_DIST);
+
+ describe('NormDist', () => {
+ it('Value is normal', () => {
+ const x = NumberValueObject.create(15.2069);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toBe(0.9893246572880974);
+ });
+
+ it('StandardDev value test', () => {
+ const x = NumberValueObject.create(15.2069);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(0);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Cumulative value test', () => {
+ const x = NumberValueObject.create(15.2069);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(false);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toBe(0.007053707723785456);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toBe(0.10564977366685524);
+ });
+
+ it('Value is null', () => {
+ const x = NullValueObject.create();
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toBe(0.06680720126885809);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(x, mean, standardDev, cumulative);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.10564977366685524, ErrorType.VALUE, 0.11653262537300785, 0.10564977366685524, 0.06680720126885809, 0.06680720126885809],
+ [0.06680720126885809, 1, 0.18009581506347705, ErrorType.VALUE, 0.012224472655044727, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/norm-dist/index.ts b/packages/engine-formula/src/functions/statistical/norm-dist/index.ts
new file mode 100644
index 0000000000..1cae84f44b
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-dist/index.ts
@@ -0,0 +1,104 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { normalCDF, normalPDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class NormDist extends BaseFunction {
+ override minParams = 4;
+
+ override maxParams = 4;
+
+ override calculate(
+ x: BaseValueObject,
+ mean: BaseValueObject,
+ standardDev: BaseValueObject,
+ cumulative: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getRowCount() : 1,
+ mean.isArray() ? (mean as ArrayValueObject).getRowCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getRowCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ x.isArray() ? (x as ArrayValueObject).getColumnCount() : 1,
+ mean.isArray() ? (mean as ArrayValueObject).getColumnCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getColumnCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType.NA));
+ const meanArray = expandArrayValueObject(maxRowLength, maxColumnLength, mean, ErrorValueObject.create(ErrorType.NA));
+ const standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType.NA));
+ const cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
+ const meanObject = meanArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const standardDevObject = standardDevArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(xObject, meanObject, standardDevObject, cumulativeObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ xObject: BaseValueObject,
+ meanObject: BaseValueObject,
+ standardDevObject: BaseValueObject,
+ cumulativeObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, meanObject, standardDevObject, cumulativeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_xObject, _meanObject, _standardDevObject, _cumulativeObject] = variants as BaseValueObject[];
+
+ const xValue = +_xObject.getValue();
+ const meanValue = +_meanObject.getValue();
+ const standardDevValue = +_standardDevObject.getValue();
+ const cumulativeValue = +_cumulativeObject.getValue();
+
+ if (standardDevValue <= 0) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ let result;
+
+ if (cumulativeValue) {
+ result = normalCDF(xValue, meanValue, standardDevValue);
+ } else {
+ result = normalPDF(xValue, meanValue, standardDevValue);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/norm-inv/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/norm-inv/__tests__/index.spec.ts
new file mode 100644
index 0000000000..955c3090a7
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-inv/__tests__/index.spec.ts
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { NormInv } from '../index';
+
+describe('Test normInv function', () => {
+ const testFunction = new NormInv(FUNCTION_NAMES_STATISTICAL.NORM_INV);
+
+ describe('NormInv', () => {
+ it('Value is normal', () => {
+ const probability = NumberValueObject.create(0.2069);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, mean, standardDev);
+ expect(getObjectValue(result)).toBe(2.7311009929896484);
+ });
+
+ it('StandardDev value test', () => {
+ const probability = NumberValueObject.create(0.2069);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(0);
+ const result = testFunction.calculate(probability, mean, standardDev);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is normal string', () => {
+ const probability = StringValueObject.create('test');
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, mean, standardDev);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const probability = BooleanValueObject.create(true);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, mean, standardDev);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const probability = NullValueObject.create();
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, mean, standardDev);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const probability = ErrorValueObject.create(ErrorType.NAME);
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, mean, standardDev);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const probability = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const mean = NumberValueObject.create(6);
+ const standardDev = NumberValueObject.create(4);
+ const result = testFunction.calculate(probability, mean, standardDev);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/norm-inv/index.ts b/packages/engine-formula/src/functions/statistical/norm-inv/index.ts
new file mode 100644
index 0000000000..2dbe7d017a
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-inv/index.ts
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { normalINV } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class NormInv extends BaseFunction {
+ override minParams = 3;
+
+ override maxParams = 3;
+
+ override calculate(
+ probability: BaseValueObject,
+ mean: BaseValueObject,
+ standardDev: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getRowCount() : 1,
+ mean.isArray() ? (mean as ArrayValueObject).getRowCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ probability.isArray() ? (probability as ArrayValueObject).getColumnCount() : 1,
+ mean.isArray() ? (mean as ArrayValueObject).getColumnCount() : 1,
+ standardDev.isArray() ? (standardDev as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType.NA));
+ const meanArray = expandArrayValueObject(maxRowLength, maxColumnLength, mean, ErrorValueObject.create(ErrorType.NA));
+ const standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
+ const meanObject = meanArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const standardDevObject = standardDevArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(probabilityObject, meanObject, standardDevObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ probabilityObject: BaseValueObject,
+ meanObject: BaseValueObject,
+ standardDevObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, meanObject, standardDevObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_probabilityObject, _meanObject, _standardDevObject] = variants as BaseValueObject[];
+
+ const probabilityValue = +_probabilityObject.getValue();
+ const meanValue = +_meanObject.getValue();
+ const standardDevValue = +_standardDevObject.getValue();
+
+ if (probabilityValue <= 0 || probabilityValue >= 1 || standardDevValue <= 0) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = normalINV(probabilityValue, meanValue, standardDevValue);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/norm-s-dist/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/norm-s-dist/__tests__/index.spec.ts
new file mode 100644
index 0000000000..37bb0f92e5
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-s-dist/__tests__/index.spec.ts
@@ -0,0 +1,94 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { NormSDist } from '../index';
+
+describe('Test normSDist function', () => {
+ const testFunction = new NormSDist(FUNCTION_NAMES_STATISTICAL.NORM_S_DIST);
+
+ describe('NormSDist', () => {
+ it('Value is normal', () => {
+ const z = NumberValueObject.create(1.2069);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(z, cumulative);
+ expect(getObjectValue(result)).toBe(0.8862646711511419);
+ });
+
+ it('Cumulative value test', () => {
+ const z = NumberValueObject.create(1.2069);
+ const cumulative = BooleanValueObject.create(false);
+ const result = testFunction.calculate(z, cumulative);
+ expect(getObjectValue(result)).toBe(0.19258024822910252);
+ });
+
+ it('Value is normal string', () => {
+ const z = StringValueObject.create('test');
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(z, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const z = BooleanValueObject.create(true);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(z, cumulative);
+ expect(getObjectValue(result)).toBe(0.8413447460685429);
+ });
+
+ it('Value is null', () => {
+ const z = NullValueObject.create();
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(z, cumulative);
+ expect(getObjectValue(result)).toBe(0.5);
+ });
+
+ it('Value is error', () => {
+ const z = ErrorValueObject.create(ErrorType.NAME);
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(z, cumulative);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const z = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const cumulative = BooleanValueObject.create(true);
+ const result = testFunction.calculate(z, cumulative);
+ expect(getObjectValue(result)).toStrictEqual([
+ [0.8413447460685429, ErrorType.VALUE, 0.8906514475743081, 0.8413447460685429, 0.5, 0.5],
+ [0.5, 1, 0.9903581300546417, ErrorType.VALUE, 0.0013498980316301035, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/norm-s-dist/index.ts b/packages/engine-formula/src/functions/statistical/norm-s-dist/index.ts
new file mode 100644
index 0000000000..c20f15b218
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-s-dist/index.ts
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { normalCDF, normalPDF } from '../../../basics/statistical';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class NormSDist extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(
+ z: BaseValueObject,
+ cumulative: BaseValueObject
+ ): BaseValueObject {
+ const maxRowLength = Math.max(
+ z.isArray() ? (z as ArrayValueObject).getRowCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ z.isArray() ? (z as ArrayValueObject).getColumnCount() : 1,
+ cumulative.isArray() ? (cumulative as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const zArray = expandArrayValueObject(maxRowLength, maxColumnLength, z, ErrorValueObject.create(ErrorType.NA));
+ const cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = zArray.mapValue((zObject, rowIndex, columnIndex) => {
+ const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ return this._handleSignleObject(zObject, cumulativeObject);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _handleSignleObject(
+ zObject: BaseValueObject,
+ cumulativeObject: BaseValueObject
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(zObject, cumulativeObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_zObject, _cumulativeObject] = variants as BaseValueObject[];
+
+ const zValue = +_zObject.getValue();
+ const cumulativeValue = +_cumulativeObject.getValue();
+
+ let result;
+
+ if (cumulativeValue) {
+ result = normalCDF(zValue, 0, 1);
+ } else {
+ result = normalPDF(zValue, 0, 1);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/statistical/norm-s-inv/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/norm-s-inv/__tests__/index.spec.ts
new file mode 100644
index 0000000000..a545133c26
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-s-inv/__tests__/index.spec.ts
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_STATISTICAL } from '../../function-names';
+import { NormSInv } from '../index';
+
+describe('Test normSInv function', () => {
+ const testFunction = new NormSInv(FUNCTION_NAMES_STATISTICAL.NORM_S_INV);
+
+ describe('NormSInv', () => {
+ it('Value is normal', () => {
+ const probability = NumberValueObject.create(0.2069);
+ const result = testFunction.calculate(probability);
+ expect(getObjectValue(result)).toBe(-0.8172247517525879);
+ });
+
+ it('Value is normal string', () => {
+ const probability = StringValueObject.create('test');
+ const result = testFunction.calculate(probability);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const probability = BooleanValueObject.create(true);
+ const result = testFunction.calculate(probability);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is null', () => {
+ const probability = NullValueObject.create();
+ const result = testFunction.calculate(probability);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is error', () => {
+ const probability = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(probability);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const probability = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(probability);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NAME],
+ ]);
+
+ const probability2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(probability2);
+ expect(getObjectValue(result2)).toStrictEqual(ErrorType.NUM);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/statistical/norm-s-inv/index.ts b/packages/engine-formula/src/functions/statistical/norm-s-inv/index.ts
new file mode 100644
index 0000000000..ce9faa2848
--- /dev/null
+++ b/packages/engine-formula/src/functions/statistical/norm-s-inv/index.ts
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { normalINV } from '../../../basics/statistical';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class NormSInv extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(probability: BaseValueObject): BaseValueObject {
+ if (probability.isArray()) {
+ const resultArray = (probability as ArrayValueObject).mapValue((probabilityObject) => this._handleSignleObject(probabilityObject));
+
+ if ((probability as ArrayValueObject).getRowCount() === 1 && (probability as ArrayValueObject).getColumnCount() === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ return this._handleSignleObject(probability);
+ }
+
+ private _handleSignleObject(probabilityObject: BaseValueObject): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_probabilityObject] = variants as BaseValueObject[];
+
+ const probabilityValue = +_probabilityObject.getValue();
+
+ if (probabilityValue <= 0 || probabilityValue >= 1) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = normalINV(probabilityValue, 0, 1);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/en-US.ts b/packages/sheets-formula/src/locale/function-list/compatibility/en-US.ts
index 1fe845181c..36cd6a2509 100644
--- a/packages/sheets-formula/src/locale/function-list/compatibility/en-US.ts
+++ b/packages/sheets-formula/src/locale/function-list/compatibility/en-US.ts
@@ -25,8 +25,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value between A and B at which to evaluate the function.' },
+ alpha: { name: 'alpha', detail: 'A parameter of the distribution.' },
+ beta: { name: 'beta', detail: 'A parameter of the distribution.' },
+ A: { name: 'A', detail: 'A lower bound to the interval of x.' },
+ B: { name: 'B', detail: 'An upper bound to the interval of x.' },
},
},
BETAINV: {
@@ -39,8 +42,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the beta distribution.' },
+ alpha: { name: 'alpha', detail: 'A parameter of the distribution.' },
+ beta: { name: 'beta', detail: 'A parameter of the distribution.' },
+ A: { name: 'A', detail: 'A lower bound to the interval of x.' },
+ B: { name: 'B', detail: 'An upper bound to the interval of x.' },
},
},
BINOMDIST: {
@@ -53,13 +59,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: 'number_s', detail: 'The number of successes in trials.' },
+ trials: { name: 'trials', detail: 'The number of independent trials.' },
+ probabilityS: { name: 'probability_s', detail: 'The probability of success on each trial.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, BINOMDIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
CHIDIST: {
- description: 'Returns the one-tailed probability of the chi-squared distribution',
- abstract: 'Returns the one-tailed probability of the chi-squared distribution',
+ description: 'Returns the right-tailed probability of the chi-squared distribution.',
+ abstract: 'Returns the right-tailed probability of the chi-squared distribution.',
links: [
{
title: 'Instruction',
@@ -67,13 +75,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which you want to evaluate the distribution.' },
+ degFreedom: { name: 'deg_freedom', detail: 'The number of degrees of freedom.' },
},
},
CHIINV: {
- description: 'Returns the inverse of the one-tailed probability of the chi-squared distribution',
- abstract: 'Returns the inverse of the one-tailed probability of the chi-squared distribution',
+ description: 'Returns the inverse of the right-tailed probability of the chi-squared distribution.',
+ abstract: 'Returns the inverse of the right-tailed probability of the chi-squared distribution.',
links: [
{
title: 'Instruction',
@@ -81,8 +89,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the chi-squared distribution.' },
+ degFreedom: { name: 'deg_freedom', detail: 'The number of degrees of freedom.' },
},
},
CHITEST: {
@@ -95,13 +103,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: 'actual_range', detail: 'The range of data that contains observations to test against expected values.' },
+ expectedRange: { name: 'expected_range', detail: 'The range of data that contains the ratio of the product of row totals and column totals to the grand total.' },
},
},
CONFIDENCE: {
- description: 'Returns the confidence interval for a population mean',
- abstract: 'Returns the confidence interval for a population mean',
+ description: 'Returns the confidence interval for a population mean, using a normal distribution.',
+ abstract: 'Returns the confidence interval for a population mean, using a normal distribution.',
links: [
{
title: 'Instruction',
@@ -109,13 +117,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: 'The significance level used to compute the confidence level. The confidence level equals 100*(1 - alpha)%, or in other words, an alpha of 0.05 indicates a 95 percent confidence level.' },
+ standardDev: { name: 'standard_dev', detail: 'The population standard deviation for the data range and is assumed to be known.' },
+ size: { name: 'size', detail: 'The sample size.' },
},
},
COVAR: {
- description: 'Returns covariance, the average of the products of paired deviations',
- abstract: 'Returns covariance, the average of the products of paired deviations',
+ description: 'Returns population covariance, the average of the products of deviations for each data point pair in two data sets.',
+ abstract: 'Returns population covariance',
links: [
{
title: 'Instruction',
@@ -123,8 +132,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: 'array1', detail: 'A first range of cell values.' },
+ array2: { name: 'array2', detail: 'A second range of cell values.' },
},
},
CRITBINOM: {
@@ -137,8 +146,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: 'trials', detail: 'The number of Bernoulli trials.' },
+ probabilityS: { name: 'probability_s', detail: 'The probability of success on each trial.' },
+ alpha: { name: 'alpha', detail: 'The criterion value.' },
},
},
EXPONDIST: {
@@ -151,13 +161,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which you want to evaluate the distribution.' },
+ lambda: { name: 'lambda', detail: 'The parameter value.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, EXPONDIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
FDIST: {
- description: 'Returns the F probability distribution',
- abstract: 'Returns the F probability distribution',
+ description: 'Returns the (right-tailed) F probability distribution',
+ abstract: 'Returns the (right-tailed) F probability distribution',
links: [
{
title: 'Instruction',
@@ -165,13 +176,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which to evaluate the function.' },
+ degFreedom1: { name: 'deg_freedom1', detail: 'The numerator degrees of freedom.' },
+ degFreedom2: { name: 'deg_freedom2', detail: 'The denominator degrees of freedom.' },
},
},
FINV: {
- description: 'Returns the inverse of the F probability distribution',
- abstract: 'Returns the inverse of the F probability distribution',
+ description: 'Returns the inverse of the (right-tailed) F probability distribution',
+ abstract: 'Returns the inverse of the (right-tailed) F probability distribution',
links: [
{
title: 'Instruction',
@@ -179,8 +191,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the F cumulative distribution.' },
+ degFreedom1: { name: 'deg_freedom1', detail: 'The numerator degrees of freedom.' },
+ degFreedom2: { name: 'deg_freedom2', detail: 'The denominator degrees of freedom.' },
},
},
FTEST: {
@@ -193,8 +206,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: 'array1', detail: 'The first array or range of data.' },
+ array2: { name: 'array2', detail: 'The second array or range of data.' },
},
},
GAMMADIST: {
@@ -305,8 +318,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value for which you want the distribution.' },
+ mean: { name: 'mean', detail: 'The arithmetic mean of the distribution.' },
+ standardDev: { name: 'standard_dev', detail: 'The standard deviation of the distribution.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, NORMDIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
NORMINV: {
@@ -319,8 +334,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability corresponding to the normal distribution.' },
+ mean: { name: 'mean', detail: 'The arithmetic mean of the distribution.' },
+ standardDev: { name: 'standard_dev', detail: 'The standard deviation of the distribution.' },
},
},
NORMSDIST: {
@@ -333,8 +349,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: 'The value for which you want the distribution.' },
},
},
NORMSINV: {
@@ -347,8 +362,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability corresponding to the normal distribution.' },
},
},
PERCENTILE: {
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/ja-JP.ts b/packages/sheets-formula/src/locale/function-list/compatibility/ja-JP.ts
index 802147692c..302fe267b7 100644
--- a/packages/sheets-formula/src/locale/function-list/compatibility/ja-JP.ts
+++ b/packages/sheets-formula/src/locale/function-list/compatibility/ja-JP.ts
@@ -25,8 +25,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: 'その関数を計算するために使用される、下限値と上限値の間の値。' },
+ alpha: { name: 'alpha', detail: '分布の最初のパラメータ。' },
+ beta: { name: 'beta', detail: '分布の 2 番目のパラメーター。' },
+ A: { name: '下限', detail: '関数の下限。デフォルト値は 0 です。' },
+ B: { name: '上限', detail: '関数の上限。デフォルト値は 1 です。' },
},
},
BETAINV: {
@@ -39,8 +42,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'β分布における確率を指定します。' },
+ alpha: { name: 'alpha', detail: '分布の最初のパラメータ。' },
+ beta: { name: 'beta', detail: '分布の 2 番目のパラメーター。' },
+ A: { name: '下限', detail: '関数の下限。デフォルト値は 0 です。' },
+ B: { name: '上限', detail: '関数の上限。デフォルト値は 1 です。' },
},
},
BINOMDIST: {
@@ -53,13 +59,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: '成功数', detail: '試行における成功数を指定します。' },
+ trials: { name: '試行回数', detail: '独立試行の回数を指定します。' },
+ probabilityS: { name: '成功率', detail: '各試行が成功する確率を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
CHIDIST: {
- description: 'カイ 2 乗分布の片側確率の値を返します。',
- abstract: 'カイ 2 乗分布の片側確率の値を返します。',
+ description: 'カイ 2 乗分布の右側確率の値を返します。',
+ abstract: 'カイ 2 乗分布の右側確率の値を返します。',
links: [
{
title: '指導',
@@ -67,13 +75,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '分布の評価に使用する値を指定します。' },
+ degFreedom: { name: '自由度', detail: '自由度を表す数値を指定します。' },
},
},
CHIINV: {
- description: 'カイ 2 乗分布の片側確率の逆関数の値を返します。',
- abstract: 'カイ 2 乗分布の片側確率の逆関数の値を返します。',
+ description: 'カイ 2 乗分布の右側確率の逆関数の値を返します。',
+ abstract: 'カイ 2 乗分布の右側確率の逆関数の値を返します。',
links: [
{
title: '指導',
@@ -81,8 +89,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'カイ 2 乗分布における確率を指定します。' },
+ degFreedom: { name: '自由度', detail: '自由度を表す数値を指定します。' },
},
},
CHITEST: {
@@ -95,13 +103,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: '実測値範囲', detail: '期待値に対する検定の実測値が入力されているデータ範囲を指定します。' },
+ expectedRange: { name: '期待値範囲', detail: '期待値が入力されているデータ範囲を指定します。実測値と期待値では、行方向の値の合計と列方向の値の合計がそれぞれ等しくなっている必要があります。' },
},
},
CONFIDENCE: {
- description: '母集団に対する信頼区間を返します。',
- abstract: '母集団に対する信頼区間を返します。',
+ description: '正規分布を使用して、母集団の平均に対する信頼区間を求めます。',
+ abstract: '正規分布を使用して、母集団の平均に対する信頼区間を求めます。',
links: [
{
title: '指導',
@@ -109,13 +117,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '信頼度を計算するために使用する有意水準を指定します。 信頼度は 100*(1- α)% で計算されます。つまり、α が 0.05 であるとき、信頼度は 95% になります。' },
+ standardDev: { name: '標準偏差', detail: 'データ範囲の母標準偏差を指定します。これは既知の値であると仮定されます。' },
+ size: { name: '標本数', detail: '標本数を指定します。' },
},
},
COVAR: {
- description: '共分散を返します。共分散とは、2 組の対応するデータ間での標準偏差の積の平均値です。',
- abstract: '共分散を返します。共分散とは、2 組の対応するデータ間での標準偏差の積の平均値です。',
+ description: '母共分散 (2 組の対応するデータ間での標準偏差の積の平均値) を返します。',
+ abstract: '母共分散を返します。',
links: [
{
title: '指導',
@@ -123,8 +132,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '配列1', detail: 'セル値の最初の範囲。' },
+ array2: { name: '配列2', detail: 'セル値の 2 番目の範囲。' },
},
},
CRITBINOM: {
@@ -137,8 +146,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '試行回数', detail: 'ベルヌーイ試行の回数を指定します。' },
+ probabilityS: { name: '成功率', detail: '各試行が成功する確率を指定します。' },
+ alpha: { name: '目標確率', detail: '基準値を指定します。' },
},
},
EXPONDIST: {
@@ -151,13 +161,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '分布の評価に使用する値を指定します。' },
+ lambda: { name: 'lambda', detail: 'パラメーターの値を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
FDIST: {
- description: 'F 分布の確率関数の値を返します。',
- abstract: 'F 分布の確率関数の値を返します。',
+ description: 'F 分布の右側確率関数の値を返します。',
+ abstract: 'F 分布の右側確率関数の値を返します。',
links: [
{
title: '指導',
@@ -165,13 +176,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '関数に代入する値を指定します。' },
+ degFreedom1: { name: '自由度の分子', detail: '自由度の分子を指定します。' },
+ degFreedom2: { name: '自由度の分母', detail: '自由度の分母を指定します。' },
},
},
FINV: {
- description: 'F 分布の確率関数の逆関数値を返します。',
- abstract: 'F 分布の確率関数の逆関数値を返します。',
+ description: 'F 分布の右側確率関数の逆関数値を返します。',
+ abstract: 'F 分布の右側確率関数の逆関数値を返します。',
links: [
{
title: '指導',
@@ -179,8 +191,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'F 累積分布における確率を指定します。' },
+ degFreedom1: { name: '自由度の分子', detail: '自由度の分子を指定します。' },
+ degFreedom2: { name: '自由度の分母', detail: '自由度の分母を指定します。' },
},
},
FTEST: {
@@ -193,8 +206,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '配列1', detail: '比較対象となる一方のデータを含む配列またはセル範囲を指定します。' },
+ array2: { name: '配列2', detail: '比較対象となるもう一方のデータを含む配列またはセル範囲を指定します。' },
},
},
GAMMADIST: {
@@ -305,8 +318,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '関数に代入する値を指定します。' },
+ mean: { name: '平均', detail: '対象となる分布の算術平均 (相加平均) を指定します。' },
+ standardDev: { name: '標準偏差', detail: '対象となる分布の標準偏差を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
NORMINV: {
@@ -319,8 +334,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: '正規分布における確率を指定します。' },
+ mean: { name: '平均', detail: '対象となる分布の算術平均 (相加平均) を指定します。' },
+ standardDev: { name: '標準偏差', detail: '対象となる分布の標準偏差を指定します。' },
},
},
NORMSDIST: {
@@ -333,8 +349,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: '関数に代入する値を指定します。' },
},
},
NORMSINV: {
@@ -347,8 +362,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: '正規分布における確率を指定します。' },
},
},
PERCENTILE: {
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/vi-VN.ts b/packages/sheets-formula/src/locale/function-list/compatibility/vi-VN.ts
index ec40bab82c..5e87cc7033 100644
--- a/packages/sheets-formula/src/locale/function-list/compatibility/vi-VN.ts
+++ b/packages/sheets-formula/src/locale/function-list/compatibility/vi-VN.ts
@@ -25,8 +25,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ x: { name: 'số', detail: 'Giá trị được sử dụng để tính toán hàm của nó, giữa giá trị giới hạn dưới và giá trị giới hạn trên.' },
+ alpha: { name: 'alpha', detail: 'Tham số đầu tiên của phân phối.' },
+ beta: { name: 'beta', detail: 'Tham số thứ hai của phân phối.' },
+ A: { name: 'giới hạn dưới', detail: 'Giới hạn dưới của hàm, giá trị mặc định là 0.' },
+ B: { name: 'giới hạn trên', detail: 'Giới hạn trên của hàm, giá trị mặc định là 1.' },
},
},
BETAINV: {
@@ -39,8 +42,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ probability: { name: 'xác suất', detail: 'Xác suất gắn với phân bố beta.' },
+ alpha: { name: 'alpha', detail: 'Tham số đầu tiên của phân phối.' },
+ beta: { name: 'beta', detail: 'Tham số thứ hai của phân phối.' },
+ A: { name: 'giới hạn dưới', detail: 'Giới hạn dưới của hàm, giá trị mặc định là 0.' },
+ B: { name: 'giới hạn trên', detail: 'Giới hạn trên của hàm, giá trị mặc định là 1.' },
},
},
BINOMDIST: {
@@ -53,14 +59,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ numberS: { name: 'số lần thành công', detail: 'Số lần thành công trong các phép thử.' },
+ trials: { name: 'số phép thử', detail: 'Số phép thử độc lập.' },
+ probabilityS: { name: 'xác suất thành công', detail: 'Xác suất thành công của mỗi phép thử.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu tích lũy là TRUE, hàm BINOMDIST trả về hàm phân bố tích lũy; nếu FALSE, nó trả về hàm mật độ xác suất.' },
},
},
-
CHIDIST: {
- description: 'Trả về xác suất đuôi đơn của phân phối χ2',
- abstract: 'Trả về xác suất đuôi đơn của phân phối χ2',
+ description: 'Trả về xác suất bên phải của phân bố χ2',
+ abstract: 'Trả về xác suất bên phải của phân bố χ2',
links: [
{
title: 'Giảng dạy',
@@ -68,13 +75,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ x: { name: 'số', detail: 'Giái trị bạn muốn đánh giá phân phối.' },
+ degFreedom: { name: 'bậc tự do', detail: 'Số bậc tự do.' },
},
},
CHIINV: {
- description: 'Trả về hàm nghịch đảo của xác suất đuôi đơn của phân phối χ2',
- abstract: 'Trả về hàm nghịch đảo của xác suất đuôi đơn của phân phối χ2',
+ description: 'Trả về hàm nghịch đảo của xác suất ở đuôi bên phải của phân bố χ2.',
+ abstract: 'Trả về hàm nghịch đảo của xác suất ở đuôi bên phải của phân bố χ2.',
links: [
{
title: 'Giảng dạy',
@@ -82,8 +89,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ probability: { name: 'xác suất', detail: 'Xác suất liên quan đến phân phối χ2.' },
+ degFreedom: { name: 'bậc tự do', detail: 'Số bậc tự do.' },
},
},
CHITEST: {
@@ -96,13 +103,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ actualRange: { name: 'phạm vi quan sát', detail: 'Phạm vi dữ liệu chứa các quan sát để kiểm thử đối với các giá trị dự kiến.' },
+ expectedRange: { name: 'phạm vi dự kiến', detail: 'Phạm vi dữ liệu chứa tỷ lệ của phép nhân tổng hàng và tổng cột với tổng cộng.' },
},
},
CONFIDENCE: {
- description: 'Trả về khoảng tin cậy cho giá trị trung bình của tổng thể',
- abstract: 'Trả về khoảng tin cậy cho giá trị trung bình của tổng thể',
+ description: 'Trả về khoảng tin cậy của trung bình tổng thể, bằng cách dùng phân bố chuẩn hóa.',
+ abstract: 'Trả về khoảng tin cậy của trung bình tổng thể, bằng cách dùng phân bố chuẩn hóa.',
links: [
{
title: 'Giảng dạy',
@@ -110,13 +117,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ alpha: { name: 'alpha', detail: 'Mức quan trọng được dùng để tính toán mức tin cậy. Mức tin cậy bằng 100*(1 - alpha)%, hay nói cách khác, alpha 0,05 cho biết mức tin cậy 95 phần trăm.' },
+ standardDev: { name: 'Độ lệch chuẩn tổng', detail: 'Độ lệch chuẩn tổng thể cho phạm vi dữ liệu và được giả định là đã được xác định.' },
+ size: { name: 'cỡ mẫu', detail: 'Cỡ mẫu.' },
},
},
COVAR: {
- description: 'Trả về hiệp phương sai (trung bình của tích các độ lệch cặp)',
- abstract: 'Trả về hiệp phương sai (trung bình của tích các độ lệch cặp)',
+ description: 'Trả về hiệp phương sai của tập hợp, trung bình tích của các độ lệnh cho mỗi cặp điểm dữ liệu trong hai tập dữ liệu.',
+ abstract: 'Trả về hiệp phương sai của tập hợp',
links: [
{
title: 'Giảng dạy',
@@ -124,8 +132,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ array1: { name: 'mảng 1', detail: 'Phạm vi giá trị ô đầu tiên.' },
+ array2: { name: 'mảng 2', detail: 'Phạm vi giá trị ô thứ hai.' },
},
},
CRITBINOM: {
@@ -138,8 +146,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ trials: { name: 'số phép thử', detail: 'Số phép thử Bernoulli.' },
+ probabilityS: { name: 'xác suất thành công', detail: 'Xác suất thành công của mỗi phép thử.' },
+ alpha: { name: 'xác suất mục tiêu', detail: 'Giá trị tiêu chí.' },
},
},
EXPONDIST: {
@@ -152,13 +161,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ x: { name: 'số', detail: 'Giái trị bạn muốn đánh giá phân phối.' },
+ lambda: { name: 'lambda', detail: 'Giá trị tham số.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu lũy tích là ĐÚNG thì EXPONDIST trả về hàm phân bố lũy tích; nếu SAI, nó trả về hàm mật độ xác suất.' },
},
},
FDIST: {
- description: 'Trả về phân phối xác suất F',
- abstract: 'Trả về phân phối xác suất F',
+ description: 'Trả về phân bố xác suất F (đuôi bên phải)',
+ abstract: 'Trả về phân bố xác suất F (đuôi bên phải)',
links: [
{
title: 'Giảng dạy',
@@ -166,13 +176,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ x: { name: 'số', detail: 'Giá trị để đánh giá hàm.' },
+ degFreedom1: { name: 'bậc tự do ở tử số', detail: 'Bậc tự do ở tử số.' },
+ degFreedom2: { name: 'bậc tự do ở mẫu số.', detail: 'Bậc tự do ở mẫu số.' },
},
},
FINV: {
- description: 'Trả về hàm nghịch đảo của phân phối xác suất F',
- abstract: 'Trả về hàm nghịch đảo của phân phối xác suất F',
+ description: 'Trả về giá trị đảo của phân bố xác suất F (đuôi bên phải).',
+ abstract: 'Trả về giá trị đảo của phân bố xác suất F (đuôi bên phải).',
links: [
{
title: 'Giảng dạy',
@@ -180,8 +191,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ probability: { name: 'xác suất', detail: 'Xác suất gắn với phân bố lũy tích F.' },
+ degFreedom1: { name: 'bậc tự do ở tử số', detail: 'Bậc tự do ở tử số.' },
+ degFreedom2: { name: 'bậc tự do ở mẫu số.', detail: 'Bậc tự do ở mẫu số.' },
},
},
FTEST: {
@@ -194,8 +206,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ array1: { name: 'mảng 1', detail: 'Mảng thứ nhất của phạm vi dữ liệu.' },
+ array2: { name: 'mảng 2', detail: 'Mảng thứ hai của phạm vi dữ liệu.' },
},
},
@@ -307,8 +319,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ x: { name: 'x', detail: 'Giá trị mà bạn muốn có phân bố của nó.' },
+ mean: { name: 'trung độ số', detail: 'Trung độ số học của phân phối.' },
+ standardDev: { name: 'Độ lệch chuẩn', detail: 'Độ lệch chuẩn của phân phối.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu lũy tích là ĐÚNG thì NORMDIST trả về hàm phân bố lũy tích; nếu SAI, nó trả về hàm mật độ xác suất.' },
},
},
NORMINV: {
@@ -321,8 +335,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ probability: { name: 'xác suất', detail: 'Một xác suất tương ứng với phân bố chuẩn.' },
+ mean: { name: 'trung độ số', detail: 'Trung độ số học của phân phối.' },
+ standardDev: { name: 'Độ lệch chuẩn', detail: 'Độ lệch chuẩn của phân phối.' },
},
},
NORMSDIST: {
@@ -335,8 +350,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'thứ nhất' },
- number2: { name: 'number2', detail: 'thứ hai' },
+ z: { name: 'z', detail: 'Giá trị mà bạn muốn có phân bố của nó.' },
},
},
@@ -350,8 +364,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'tham số thứ nhất' },
- number2: { name: 'number2', detail: 'tham số thứ hai' },
+ probability: { name: 'xác suất', detail: 'Một xác suất tương ứng với phân bố chuẩn.' },
},
},
PERCENTILE: {
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/zh-CN.ts b/packages/sheets-formula/src/locale/function-list/compatibility/zh-CN.ts
index 89be821b94..a3269bdf4b 100644
--- a/packages/sheets-formula/src/locale/function-list/compatibility/zh-CN.ts
+++ b/packages/sheets-formula/src/locale/function-list/compatibility/zh-CN.ts
@@ -25,8 +25,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算其函数的值,介于下限值和上限值之间。' },
+ alpha: { name: 'alpha', detail: '分布的第一个参数。' },
+ beta: { name: 'beta', detail: '分布的第二个参数。' },
+ A: { name: '下限', detail: '函数的下限,默认值为 0。' },
+ B: { name: '上限', detail: '函数的上限,默认值为 1。' },
},
},
BETAINV: {
@@ -39,8 +42,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '与 beta 分布相关的概率。' },
+ alpha: { name: 'alpha', detail: '分布的第一个参数。' },
+ beta: { name: 'beta', detail: '分布的第二个参数。' },
+ A: { name: '下限', detail: '函数的下限,默认值为 0。' },
+ B: { name: '上限', detail: '函数的上限,默认值为 1。' },
},
},
BINOMDIST: {
@@ -53,13 +59,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: '成功次数', detail: '试验的成功次数。' },
+ trials: { name: '试验次数', detail: '独立试验次数。' },
+ probabilityS: { name: '成功概率', detail: '每次试验成功的概率。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。如果为 TRUE,则 BINOMDIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
CHIDIST: {
- description: '返回 χ2 分布的单尾概率',
- abstract: '返回 χ2 分布的单尾概率',
+ description: '返回 χ2 分布的右尾概率。',
+ abstract: '返回 χ2 分布的右尾概率。',
links: [
{
title: '教学',
@@ -67,13 +75,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算分布的数值。' },
+ degFreedom: { name: '自由度', detail: '自由度数。' },
},
},
CHIINV: {
- description: '返回 χ2 分布的单尾概率的反函数',
- abstract: '返回 χ2 分布的单尾概率的反函数',
+ description: '返回 χ2 分布的右尾概率的反函数。',
+ abstract: '返回 χ2 分布的右尾概率的反函数。',
links: [
{
title: '教学',
@@ -81,8 +89,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '与 χ2 分布相关联的概率。' },
+ degFreedom: { name: '自由度', detail: '自由度数。' },
},
},
CHITEST: {
@@ -95,13 +103,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: '观察范围', detail: '包含观察值的数据区域,用于检验预期值。' },
+ expectedRange: { name: '预期范围', detail: '包含行列汇总的乘积与总计值之比率的数据区域。' },
},
},
CONFIDENCE: {
- description: '返回总体平均值的置信区间',
- abstract: '返回总体平均值的置信区间',
+ description: '使用正态分布返回总体平均值的置信区间。',
+ abstract: '使用正态分布返回总体平均值的置信区间。',
links: [
{
title: '教学',
@@ -109,13 +117,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '用来计算置信水平的显著性水平。 置信水平等于 100*(1 - alpha)%,亦即,如果 alpha 为 0.05,则置信水平为 95%。' },
+ standardDev: { name: '总体标准偏差', detail: '数据区域的总体标准偏差,假定为已知。' },
+ size: { name: '样本大小', detail: '样本大小。' },
},
},
COVAR: {
- description: '返回协方差(成对偏差乘积的平均值)',
- abstract: '返回协方差(成对偏差乘积的平均值)',
+ description: '返回总体协方差,即两个数据集中每对数据点的偏差乘积的平均值。',
+ abstract: '返回总体协方差',
links: [
{
title: '教学',
@@ -123,8 +132,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '数组1', detail: '第一个单元格值区域。' },
+ array2: { name: '数组2', detail: '第二个单元格值区域。' },
},
},
CRITBINOM: {
@@ -137,8 +146,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '试验次数', detail: '伯努利试验的次数。' },
+ probabilityS: { name: '成功概率', detail: '每次试验成功的概率。' },
+ alpha: { name: '目标概率', detail: '临界值。' },
},
},
EXPONDIST: {
@@ -151,13 +161,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算分布的数值。' },
+ lambda: { name: 'lambda', detail: '参数值。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。 如果为 TRUE,则 EXPONDIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
FDIST: {
- description: '返回 F 概率分布',
- abstract: '返回 F 概率分布',
+ description: '返回 F 概率分布(右尾)',
+ abstract: '返回 F 概率分布(右尾)',
links: [
{
title: '教学',
@@ -165,13 +176,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算函数的值。' },
+ degFreedom1: { name: '分子自由度', detail: '分子自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '分母自由度。' },
},
},
FINV: {
- description: '返回 F 概率分布的反函数',
- abstract: '返回 F 概率分布的反函数',
+ description: '返回 F 概率分布(右尾)的反函数',
+ abstract: '返回 F 概率分布(右尾)的反函数',
links: [
{
title: '教学',
@@ -179,8 +191,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: 'F 累积分布的概率值。' },
+ degFreedom1: { name: '分子自由度', detail: '分子自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '分母自由度。' },
},
},
FTEST: {
@@ -193,8 +206,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '数组1', detail: '第一个数据数组或数据范围。' },
+ array2: { name: '数组2', detail: '第二个数据数组或数据范围。' },
},
},
GAMMADIST: {
@@ -305,8 +318,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '需要计算其分布的数值。' },
+ mean: { name: '平均值', detail: '分布的算术平均值。' },
+ standardDev: { name: '标准偏差', detail: '分布的标准偏差。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。 如果为 TRUE,则 NORMDIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
NORMINV: {
@@ -319,8 +334,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '对应于正态分布的概率。' },
+ mean: { name: '平均值', detail: '分布的算术平均值。' },
+ standardDev: { name: '标准偏差', detail: '分布的标准偏差。' },
},
},
NORMSDIST: {
@@ -333,8 +349,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: '需要计算其分布的数值。' },
},
},
NORMSINV: {
@@ -347,8 +362,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '对应于正态分布的概率。' },
},
},
PERCENTILE: {
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/zh-TW.ts b/packages/sheets-formula/src/locale/function-list/compatibility/zh-TW.ts
index 1cdd5c63f1..e7ae261236 100644
--- a/packages/sheets-formula/src/locale/function-list/compatibility/zh-TW.ts
+++ b/packages/sheets-formula/src/locale/function-list/compatibility/zh-TW.ts
@@ -25,8 +25,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用來計算其函數的值,介於下限值和上限值之間。' },
+ alpha: { name: 'alpha', detail: '分佈的第一個參數。' },
+ beta: { name: 'beta', detail: '分佈的第二個參數。' },
+ A: { name: '下限', detail: '函數的下限,預設值為 0。' },
+ B: { name: '上限', detail: '函數的上限,預設值為 1。' },
},
},
BETAINV: {
@@ -39,8 +42,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是 beta 分佈的相關機率。' },
+ alpha: { name: 'alpha', detail: '分佈的第一個參數。' },
+ beta: { name: 'beta', detail: '分佈的第二個參數。' },
+ A: { name: '下限', detail: '函數的下限,預設值為 0。' },
+ B: { name: '上限', detail: '函數的上限,預設值為 1。' },
},
},
BINOMDIST: {
@@ -53,13 +59,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: '成功次數', detail: '為實驗的成功次數。' },
+ trials: { name: '實驗次數', detail: '為獨立實驗的次數。' },
+ probabilityS: { name: '成功機率', detail: '每一次實驗的成功機率。' },
+ cumulative: { name: '累積', detail: '決定函數形式的邏輯值。如果為 TRUE,則 BINOMDIST 傳回累積分佈函數;如果為 FALSE,則傳回機率密度函數。' },
},
},
CHIDIST: {
- description: '傳回 χ2 分佈的單尾機率',
- abstract: '傳回 χ2 分佈的單尾機率',
+ description: '傳回 χ2 分佈的右尾機率',
+ abstract: '傳回 χ2 分佈的右尾機率',
links: [
{
title: '教導',
@@ -67,13 +75,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用來評估分佈的值。' },
+ degFreedom: { name: '自由度', detail: '這是自由度。' },
},
},
CHIINV: {
- description: '傳回 χ2 分佈的單尾機率的反函數',
- abstract: '傳回 χ2 分佈的單尾機率的反函數',
+ description: '傳回 χ2 分佈的右尾機率的反函數值。',
+ abstract: '傳回 χ2 分佈的右尾機率的反函數值。',
links: [
{
title: '教導',
@@ -81,8 +89,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是與 χ2 分佈相關聯的機率。' },
+ degFreedom: { name: '自由度', detail: '這是自由度。' },
},
},
CHITEST: {
@@ -95,13 +103,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: '觀察範圍', detail: '這是觀察值範圍,用來檢定預期值。' },
+ expectedRange: { name: '預期範圍', detail: '這是資料範圍,其內容為各欄總和乘各列總和後的值,再除以全部值總和的比率。' },
},
},
CONFIDENCE: {
- description: '傳回總體平均值的置信區間',
- abstract: '傳回總體平均值的置信區間',
+ description: '使用常態分佈傳回總體平均值的置信區間。',
+ abstract: '使用常態分佈傳回總體平均值的置信區間。',
links: [
{
title: '教導',
@@ -109,13 +117,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '用於計算置信水準的顯著水準。置信水準等於 100*(1 - alpha)%,換句話說,alpha 0.05 表示信賴水準為 95%。' },
+ standardDev: { name: '總體標準差', detail: '假設資料範圍的總體標準差已知。' },
+ size: { name: '樣本大小', detail: '這是樣本大小。' },
},
},
COVAR: {
- description: '傳回協方差(成對偏差乘積的平均值)',
- abstract: '傳回協方差(成對偏差乘積的平均值)',
+ description: '傳回總體協方差,即兩個資料集中每對資料點的偏差乘積的平均值。',
+ abstract: '傳回總體協方差',
links: [
{
title: '教導',
@@ -123,8 +132,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '陣列1', detail: '第一個儲存格值範圍。' },
+ array2: { name: '陣列2', detail: '第二個儲存格值範圍。' },
},
},
CRITBINOM: {
@@ -137,8 +146,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '實驗次數', detail: '伯努利實驗的次數。' },
+ probabilityS: { name: '成功機率', detail: '每一次實驗的成功機率。' },
+ alpha: { name: '目標機率', detail: '這是臨界值。' },
},
},
EXPONDIST: {
@@ -151,13 +161,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用來評估分佈的值。' },
+ lambda: { name: 'lambda', detail: '這是參數值。' },
+ cumulative: { name: '累積', detail: ' 這是決定函數形式的邏輯值。 如果為 TRUE,EXPONDIST 會傳回累積分佈函數;如果為 FALSE,則會傳回機率密度函數。' },
},
},
FDIST: {
- description: '返回 F 機率分佈',
- abstract: '返回 F 機率分佈',
+ description: '返回 F 機率分佈(右尾)',
+ abstract: '返回 F 機率分佈(右尾)',
links: [
{
title: '教導',
@@ -165,13 +176,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用於評估函數的值。' },
+ degFreedom1: { name: '分子自由度', detail: '這是分子的自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '這是分母的自由度。' },
},
},
FINV: {
- description: '傳回 F 機率分佈的反函數',
- abstract: '傳回 F 機率分佈的反函數',
+ description: '傳回 F 機率分佈(右尾)的反函數',
+ abstract: '傳回 F 機率分佈(右尾)的反函數',
links: [
{
title: '教導',
@@ -179,8 +191,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: 'F 累積分佈相關的機率' },
+ degFreedom1: { name: '分子自由度', detail: '這是分子的自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '這是分母的自由度。' },
},
},
FTEST: {
@@ -193,8 +206,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '陣列1', detail: '這是第一個陣列或資料範圍。' },
+ array2: { name: '陣列2', detail: '這是第一個陣列或資料範圍。' },
},
},
GAMMADIST: {
@@ -305,8 +318,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '這是您要找出分佈的數值。' },
+ mean: { name: '平均值', detail: '這是分佈的算術平均值。' },
+ standardDev: { name: '標準差', detail: '這是分佈的標準差。' },
+ cumulative: { name: '累積', detail: ' 這是決定函數形式的邏輯值。 如果為 TRUE,NORMDIST 會傳回累積分佈函數;如果為 FALSE,則會傳回機率密度函數。' },
},
},
NORMINV: {
@@ -318,8 +333,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是對應到常態分佈的機率。' },
+ mean: { name: '平均值', detail: '這是分佈的算術平均值。' },
+ standardDev: { name: '標準差', detail: '這是分佈的標準差。' },
},
},
NORMSDIST: {
@@ -332,8 +348,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: '這是您要找出分佈的數值。' },
},
},
NORMSINV: {
@@ -346,8 +361,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是對應到常態分佈的機率。' },
},
},
PERCENTILE: {
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts b/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts
index 2ec1ae91bd..873d874297 100644
--- a/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts
+++ b/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts
@@ -111,8 +111,12 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value between A and B at which to evaluate the function.' },
+ alpha: { name: 'alpha', detail: 'A parameter of the distribution.' },
+ beta: { name: 'beta', detail: 'A parameter of the distribution.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, BETA.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
+ A: { name: 'A', detail: 'A lower bound to the interval of x.' },
+ B: { name: 'B', detail: 'An upper bound to the interval of x.' },
},
},
BETA_INV: {
@@ -125,8 +129,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the beta distribution.' },
+ alpha: { name: 'alpha', detail: 'A parameter of the distribution.' },
+ beta: { name: 'beta', detail: 'A parameter of the distribution.' },
+ A: { name: 'A', detail: 'A lower bound to the interval of x.' },
+ B: { name: 'B', detail: 'An upper bound to the interval of x.' },
},
},
BINOM_DIST: {
@@ -139,8 +146,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: 'number_s', detail: 'The number of successes in trials.' },
+ trials: { name: 'trials', detail: 'The number of independent trials.' },
+ probabilityS: { name: 'probability_s', detail: 'The probability of success on each trial.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, BINOM.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
BINOM_DIST_RANGE: {
@@ -153,8 +162,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: 'trials', detail: 'The number of independent trials.' },
+ probabilityS: { name: 'probability_s', detail: 'The probability of success on each trial.' },
+ numberS: { name: 'number_s', detail: 'The number of successes in trials.' },
+ numberS2: { name: 'number_s2', detail: 'If provided, returns the probability that the number of successful trials will fall between number_s and number_s2.' },
},
},
BINOM_INV: {
@@ -167,13 +178,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: 'trials', detail: 'The number of Bernoulli trials.' },
+ probabilityS: { name: 'probability_s', detail: 'The probability of success on each trial.' },
+ alpha: { name: 'alpha', detail: 'The criterion value.' },
},
},
CHISQ_DIST: {
- description: 'Returns the cumulative beta probability density function',
- abstract: 'Returns the cumulative beta probability density function',
+ description: 'Returns the left-tailed probability of the chi-squared distribution.',
+ abstract: 'Returns the left-tailed probability of the chi-squared distribution.',
links: [
{
title: 'Instruction',
@@ -181,13 +193,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which you want to evaluate the distribution.' },
+ degFreedom: { name: 'deg_freedom', detail: 'The number of degrees of freedom.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, CHISQ.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
CHISQ_DIST_RT: {
- description: 'Returns the one-tailed probability of the chi-squared distribution',
- abstract: 'Returns the one-tailed probability of the chi-squared distribution',
+ description: 'Returns the right-tailed probability of the chi-squared distribution.',
+ abstract: 'Returns the right-tailed probability of the chi-squared distribution.',
links: [
{
title: 'Instruction',
@@ -195,13 +208,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which you want to evaluate the distribution.' },
+ degFreedom: { name: 'deg_freedom', detail: 'The number of degrees of freedom.' },
},
},
CHISQ_INV: {
- description: 'Returns the cumulative beta probability density function',
- abstract: 'Returns the cumulative beta probability density function',
+ description: 'Returns the inverse of the left-tailed probability of the chi-squared distribution.',
+ abstract: 'Returns the inverse of the left-tailed probability of the chi-squared distribution.',
links: [
{
title: 'Instruction',
@@ -209,13 +222,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the chi-squared distribution.' },
+ degFreedom: { name: 'deg_freedom', detail: 'The number of degrees of freedom.' },
},
},
CHISQ_INV_RT: {
- description: 'Returns the inverse of the one-tailed probability of the chi-squared distribution',
- abstract: 'Returns the inverse of the one-tailed probability of the chi-squared distribution',
+ description: 'Returns the inverse of the right-tailed probability of the chi-squared distribution.',
+ abstract: 'Returns the inverse of the right-tailed probability of the chi-squared distribution.',
links: [
{
title: 'Instruction',
@@ -223,8 +236,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the chi-squared distribution.' },
+ degFreedom: { name: 'deg_freedom', detail: 'The number of degrees of freedom.' },
},
},
CHISQ_TEST: {
@@ -237,13 +250,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: 'actual_range', detail: 'The range of data that contains observations to test against expected values.' },
+ expectedRange: { name: 'expected_range', detail: 'The range of data that contains the ratio of the product of row totals and column totals to the grand total.' },
},
},
CONFIDENCE_NORM: {
- description: 'Returns the confidence interval for a population mean',
- abstract: 'Returns the confidence interval for a population mean',
+ description: 'Returns the confidence interval for a population mean, using a normal distribution.',
+ abstract: 'Returns the confidence interval for a population mean, using a normal distribution.',
links: [
{
title: 'Instruction',
@@ -251,8 +264,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: 'The significance level used to compute the confidence level. The confidence level equals 100*(1 - alpha)%, or in other words, an alpha of 0.05 indicates a 95 percent confidence level.' },
+ standardDev: { name: 'standard_dev', detail: 'The population standard deviation for the data range and is assumed to be known.' },
+ size: { name: 'size', detail: 'The sample size.' },
},
},
CONFIDENCE_T: {
@@ -265,8 +279,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: 'The significance level used to compute the confidence level. The confidence level equals 100*(1 - alpha)%, or in other words, an alpha of 0.05 indicates a 95 percent confidence level.' },
+ standardDev: { name: 'standard_dev', detail: 'The population standard deviation for the data range and is assumed to be known.' },
+ size: { name: 'size', detail: 'The sample size.' },
},
},
CORREL: {
@@ -279,8 +294,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: 'array1', detail: 'A first range of cell values.' },
+ array2: { name: 'array2', detail: 'A second range of cell values.' },
},
},
COUNT: {
@@ -368,8 +383,8 @@ export default {
},
},
COVARIANCE_P: {
- description: 'Returns covariance, the average of the products of paired deviations',
- abstract: 'Returns covariance, the average of the products of paired deviations',
+ description: 'Returns population covariance, the average of the products of deviations for each data point pair in two data sets.',
+ abstract: 'Returns population covariance',
links: [
{
title: 'Instruction',
@@ -377,13 +392,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: 'array1', detail: 'A first range of cell values.' },
+ array2: { name: 'array2', detail: 'A second range of cell values.' },
},
},
COVARIANCE_S: {
- description: 'Returns the sample covariance, the average of the products deviations for each data point pair in two data sets',
- abstract: 'Returns the sample covariance, the average of the products deviations for each data point pair in two data sets',
+ description: 'Returns the sample covariance, the average of the products of deviations for each data point pair in two data sets.',
+ abstract: 'Returns the sample covariance',
links: [
{
title: 'Instruction',
@@ -391,8 +406,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: 'array1', detail: 'A first range of cell values.' },
+ array2: { name: 'array2', detail: 'A second range of cell values.' },
},
},
DEVSQ: {
@@ -405,8 +420,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: 'number1', detail: 'The fist argument for which you want to calculate the sum of squared deviations.' },
+ number2: { name: 'number2', detail: 'The 2 to 255 arguments for which you want to calculate the sum of squared deviations.' },
},
},
EXPON_DIST: {
@@ -419,8 +434,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which you want to evaluate the distribution.' },
+ lambda: { name: 'lambda', detail: 'The parameter value.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, EXPON.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
F_DIST: {
@@ -433,13 +449,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which to evaluate the function.' },
+ degFreedom1: { name: 'deg_freedom1', detail: 'The numerator degrees of freedom.' },
+ degFreedom2: { name: 'deg_freedom2', detail: 'The denominator degrees of freedom.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, F.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
F_DIST_RT: {
- description: 'Returns the F probability distribution',
- abstract: 'Returns the F probability distribution',
+ description: 'Returns the (right-tailed) F probability distribution',
+ abstract: 'Returns the (right-tailed) F probability distribution',
links: [
{
title: 'Instruction',
@@ -447,8 +465,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value at which to evaluate the function.' },
+ degFreedom1: { name: 'deg_freedom1', detail: 'The numerator degrees of freedom.' },
+ degFreedom2: { name: 'deg_freedom2', detail: 'The denominator degrees of freedom.' },
},
},
F_INV: {
@@ -461,13 +480,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the F cumulative distribution.' },
+ degFreedom1: { name: 'deg_freedom1', detail: 'The numerator degrees of freedom.' },
+ degFreedom2: { name: 'deg_freedom2', detail: 'The denominator degrees of freedom.' },
},
},
F_INV_RT: {
- description: 'Returns the inverse of the F probability distribution',
- abstract: 'Returns the inverse of the F probability distribution',
+ description: 'Returns the inverse of the (right-tailed) F probability distribution',
+ abstract: 'Returns the inverse of the (right-tailed) F probability distribution',
links: [
{
title: 'Instruction',
@@ -475,8 +495,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability associated with the F cumulative distribution.' },
+ degFreedom1: { name: 'deg_freedom1', detail: 'The numerator degrees of freedom.' },
+ degFreedom2: { name: 'deg_freedom2', detail: 'The denominator degrees of freedom.' },
},
},
F_TEST: {
@@ -489,8 +510,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: 'array1', detail: 'The first array or range of data.' },
+ array2: { name: 'array2', detail: 'The second array or range of data.' },
},
},
FISHER: {
@@ -503,8 +524,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'A numeric value for which you want the transformation.' },
},
},
FISHERINV: {
@@ -517,8 +537,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ y: { name: 'y', detail: 'The value for which you want to perform the inverse of the transformation.' },
},
},
FORECAST: {
@@ -531,8 +550,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The data point for which you want to predict a value.' },
+ knownYs: { name: "known_y's", detail: 'The dependent array or range of data.' },
+ knownXs: { name: "known_x's", detail: 'The independent array or range of data.' },
},
},
FORECAST_ETS: {
@@ -597,12 +617,13 @@ export default {
links: [
{
title: 'Instruction',
- url: 'https://support.microsoft.com/en-us/office/forecasting-functions-reference-897a2fe9-6595-4680-a0b0-93e0308d5f6e#_FORECAST.LINEAR',
+ url: 'https://support.microsoft.com/en-us/office/forecast-and-forecast-linear-functions-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The data point for which you want to predict a value.' },
+ knownYs: { name: "known_y's", detail: 'The dependent array or range of data.' },
+ knownXs: { name: "known_x's", detail: 'The independent array or range of data.' },
},
},
FREQUENCY: {
@@ -769,8 +790,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ knownYs: { name: "known_y's", detail: 'The dependent array or range of data.' },
+ knownXs: { name: "known_x's", detail: 'The independent array or range of data.' },
},
},
KURT: {
@@ -1025,8 +1046,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The value for which you want the distribution.' },
+ mean: { name: 'mean', detail: 'The arithmetic mean of the distribution.' },
+ standardDev: { name: 'standard_dev', detail: 'The standard deviation of the distribution.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, NORM.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
NORM_INV: {
@@ -1039,8 +1062,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability corresponding to the normal distribution.' },
+ mean: { name: 'mean', detail: 'The arithmetic mean of the distribution.' },
+ standardDev: { name: 'standard_dev', detail: 'The standard deviation of the distribution.' },
},
},
NORM_S_DIST: {
@@ -1053,8 +1077,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: 'The value for which you want the distribution.' },
+ cumulative: { name: 'cumulative', detail: 'A logical value that determines the form of the function. If cumulative is TRUE, NORM.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.' },
},
},
NORM_S_INV: {
@@ -1067,8 +1091,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: 'probability', detail: 'A probability corresponding to the normal distribution.' },
},
},
PEARSON: {
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts b/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts
index 763057c5a4..886b90613b 100644
--- a/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts
+++ b/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts
@@ -99,8 +99,12 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: 'その関数を計算するために使用される、下限値と上限値の間の値。' },
+ alpha: { name: 'alpha', detail: '分布の最初のパラメータ。' },
+ beta: { name: 'beta', detail: '分布の 2 番目のパラメーター。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
+ A: { name: '下限', detail: '関数の下限。デフォルト値は 0 です。' },
+ B: { name: '上限', detail: '関数の上限。デフォルト値は 1 です。' },
},
},
BETA_INV: {
@@ -113,8 +117,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'β分布における確率を指定します。' },
+ alpha: { name: 'alpha', detail: '分布の最初のパラメータ。' },
+ beta: { name: 'beta', detail: '分布の 2 番目のパラメーター。' },
+ A: { name: '下限', detail: '関数の下限。デフォルト値は 0 です。' },
+ B: { name: '上限', detail: '関数の上限。デフォルト値は 1 です。' },
},
},
BINOM_DIST: {
@@ -127,8 +134,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: '成功数', detail: '試行における成功数を指定します。' },
+ trials: { name: '試行回数', detail: '独立試行の回数を指定します。' },
+ probabilityS: { name: '成功率', detail: '各試行が成功する確率を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
BINOM_DIST_RANGE: {
@@ -141,8 +150,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '試行回数', detail: '独立試行の回数を指定します。' },
+ probabilityS: { name: '成功率', detail: '各試行が成功する確率を指定します。' },
+ numberS: { name: '成功数', detail: '試行における成功数を指定します。' },
+ numberS2: { name: '最大成功数', detail: '指定した場合、成功した試行回数が 成功数 と 最大成功数 の間に入る確率を返します。' },
},
},
BINOM_INV: {
@@ -155,13 +166,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '試行回数', detail: 'ベルヌーイ試行の回数を指定します。' },
+ probabilityS: { name: '成功率', detail: '各試行が成功する確率を指定します。' },
+ alpha: { name: '目標確率', detail: '基準値を指定します。' },
},
},
CHISQ_DIST: {
- description: '累積β確率密度関数の値を返します。',
- abstract: '累積β確率密度関数の値を返します。',
+ description: 'カイ 2 乗分布の左側確率の値を返します。',
+ abstract: 'カイ 2 乗分布の左側確率の値を返します。',
links: [
{
title: '指導',
@@ -169,13 +181,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '分布の評価に使用する値を指定します。' },
+ degFreedom: { name: '自由度', detail: '自由度を表す数値を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
CHISQ_DIST_RT: {
- description: 'カイ 2 乗分布の片側確率の値を返します。',
- abstract: 'カイ 2 乗分布の片側確率の値を返します。',
+ description: 'カイ 2 乗分布の右側確率の値を返します。',
+ abstract: 'カイ 2 乗分布の右側確率の値を返します。',
links: [
{
title: '指導',
@@ -183,13 +196,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '分布の評価に使用する値を指定します。' },
+ degFreedom: { name: '自由度', detail: '自由度を表す数値を指定します。' },
},
},
CHISQ_INV: {
- description: '累積β確率密度関数の値を返します。',
- abstract: '累積β確率密度関数の値を返します。',
+ description: 'カイ 2 乗分布の左側確率の逆関数の値を返します。',
+ abstract: 'カイ 2 乗分布の左側確率の逆関数の値を返します。',
links: [
{
title: '指導',
@@ -197,13 +210,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'カイ 2 乗分布における確率を指定します。' },
+ degFreedom: { name: '自由度', detail: '自由度を表す数値を指定します。' },
},
},
CHISQ_INV_RT: {
- description: 'カイ 2 乗分布の片側確率の逆関数の値を返します。',
- abstract: 'カイ 2 乗分布の片側確率の逆関数の値を返します。',
+ description: 'カイ 2 乗分布の右側確率の逆関数の値を返します。',
+ abstract: 'カイ 2 乗分布の右側確率の逆関数の値を返します。',
links: [
{
title: '指導',
@@ -211,8 +224,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'カイ 2 乗分布における確率を指定します。' },
+ degFreedom: { name: '自由度', detail: '自由度を表す数値を指定します。' },
},
},
CHISQ_TEST: {
@@ -225,13 +238,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: '実測値範囲', detail: '期待値に対する検定の実測値が入力されているデータ範囲を指定します。' },
+ expectedRange: { name: '期待値範囲', detail: '期待値が入力されているデータ範囲を指定します。実測値と期待値では、行方向の値の合計と列方向の値の合計がそれぞれ等しくなっている必要があります。' },
},
},
CONFIDENCE_NORM: {
- description: '母集団に対する信頼区間を返します。',
- abstract: '母集団に対する信頼区間を返します。',
+ description: '正規分布を使用して、母集団の平均に対する信頼区間を求めます。',
+ abstract: '正規分布を使用して、母集団の平均に対する信頼区間を求めます。',
links: [
{
title: '指導',
@@ -239,8 +252,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '信頼度を計算するために使用する有意水準を指定します。 信頼度は 100*(1- α)% で計算されます。つまり、α が 0.05 であるとき、信頼度は 95% になります。' },
+ standardDev: { name: '標準偏差', detail: 'データ範囲の母標準偏差を指定します。これは既知の値であると仮定されます。' },
+ size: { name: '標本数', detail: '標本数を指定します。' },
},
},
CONFIDENCE_T: {
@@ -253,8 +267,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '信頼度を計算するために使用する有意水準を指定します。 信頼度は 100*(1- α)% で計算されます。つまり、α が 0.05 であるとき、信頼度は 95% になります。' },
+ standardDev: { name: '標準偏差', detail: 'データ範囲の母標準偏差を指定します。これは既知の値であると仮定されます。' },
+ size: { name: '標本数', detail: '標本数を指定します。' },
},
},
CORREL: {
@@ -267,8 +282,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '配列1', detail: 'セル値の最初の範囲。' },
+ array2: { name: '配列2', detail: 'セル値の 2 番目の範囲。' },
},
},
COUNT: {
@@ -343,8 +358,8 @@ export default {
},
},
COVARIANCE_P: {
- description: '共分散を返します。共分散とは、2 組の対応するデータ間での標準偏差の積の平均値です。',
- abstract: '共分散を返します。共分散とは、2 組の対応するデータ間での標準偏差の積の平均値です。',
+ description: '母共分散 (2 組の対応するデータ間での標準偏差の積の平均値) を返します。',
+ abstract: '母共分散を返します。',
links: [
{
title: '指導',
@@ -352,13 +367,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '配列1', detail: 'セル値の最初の範囲。' },
+ array2: { name: '配列2', detail: 'セル値の 2 番目の範囲。' },
},
},
COVARIANCE_S: {
- description: '標本の共分散を返します。共分散とは、2 組の対応するデータ間での標準偏差の積の平均値です。',
- abstract: '標本の共分散を返します。共分散とは、2 組の対応するデータ間での標準偏差の積の平均値です。',
+ description: '標本の共分散 (2 組の対応するデータ間での標準偏差の積の平均値) を返します。',
+ abstract: '標本の共分散を返します。',
links: [
{
title: '指導',
@@ -366,8 +381,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '配列1', detail: 'セル値の最初の範囲。' },
+ array2: { name: '配列2', detail: 'セル値の 2 番目の範囲。' },
},
},
DEVSQ: {
@@ -380,8 +395,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数値1', detail: '偏差二乗の合計を計算するために使用される 1 番目のパラメーター。' },
+ number2: { name: '数値2', detail: 'パラメータ 2 ~ 255 は、二乗偏差の合計を計算するために使用されます。' },
},
},
EXPON_DIST: {
@@ -394,8 +409,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '分布の評価に使用する値を指定します。' },
+ lambda: { name: 'lambda', detail: 'パラメーターの値を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
F_DIST: {
@@ -408,13 +424,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '関数に代入する値を指定します。' },
+ degFreedom1: { name: '自由度の分子', detail: '自由度の分子を指定します。' },
+ degFreedom2: { name: '自由度の分母', detail: '自由度の分母を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
F_DIST_RT: {
- description: 'F 分布の確率関数の値を返します。',
- abstract: 'F 分布の確率関数の値を返します。',
+ description: 'F 分布の右側確率関数の値を返します。',
+ abstract: 'F 分布の右側確率関数の値を返します。',
links: [
{
title: '指導',
@@ -422,8 +440,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '値', detail: '関数に代入する値を指定します。' },
+ degFreedom1: { name: '自由度の分子', detail: '自由度の分子を指定します。' },
+ degFreedom2: { name: '自由度の分母', detail: '自由度の分母を指定します。' },
},
},
F_INV: {
@@ -436,13 +455,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'F 累積分布における確率を指定します。' },
+ degFreedom1: { name: '自由度の分子', detail: '自由度の分子を指定します。' },
+ degFreedom2: { name: '自由度の分母', detail: '自由度の分母を指定します。' },
},
},
F_INV_RT: {
- description: 'F 分布の確率関数の逆関数値を返します。',
- abstract: 'F 分布の確率関数の逆関数値を返します。',
+ description: 'F 分布の右側確率関数の逆関数値を返します。',
+ abstract: 'F 分布の右側確率関数の逆関数値を返します。',
links: [
{
title: '指導',
@@ -450,8 +470,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: 'F 累積分布における確率を指定します。' },
+ degFreedom1: { name: '自由度の分子', detail: '自由度の分子を指定します。' },
+ degFreedom2: { name: '自由度の分母', detail: '自由度の分母を指定します。' },
},
},
F_TEST: {
@@ -464,8 +485,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '配列1', detail: '比較対象となる一方のデータを含む配列またはセル範囲を指定します。' },
+ array2: { name: '配列2', detail: '比較対象となるもう一方のデータを含む配列またはセル範囲を指定します。' },
},
},
FISHER: {
@@ -478,8 +499,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '数値', detail: '変換の対象となる数値を指定します。' },
},
},
FISHERINV: {
@@ -492,8 +512,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ y: { name: '数値', detail: '逆変換の対象となる値を指定します。' },
},
},
FORECAST: {
@@ -502,12 +521,13 @@ export default {
links: [
{
title: '指導',
- url: 'https://support.microsoft.com/ja-jp/office/%E4%BA%88%E6%B8%AC%E3%81%A8%E4%BA%88%E6%B8%AC-linear-%E9%96%A2%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
+ url: 'https://support.microsoft.com/ja-jp/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '予測する従属変数の値に対する独立変数の値を、数値で示します。' },
+ knownYs: { name: '既知の y', detail: '既知の従属変数の値が入力されているセル範囲または配列を指定します。' },
+ knownXs: { name: '既知の x', detail: '既知の独立変数の値が入力されているセル範囲または配列を指定します。' },
},
},
FORECAST_ETS: {
@@ -572,12 +592,13 @@ export default {
links: [
{
title: '指導',
- url: 'https://support.microsoft.com/ja-jp/office/forecasting-%E9%96%A2%E6%95%B0-%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9-897a2fe9-6595-4680-a0b0-93e0308d5f6e#_FORECAST.LINEAR',
+ url: 'https://support.microsoft.com/ja-jp/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '予測する従属変数の値に対する独立変数の値を、数値で示します。' },
+ knownYs: { name: '既知の y', detail: '既知の従属変数の値が入力されているセル範囲または配列を指定します。' },
+ knownXs: { name: '既知の x', detail: '既知の独立変数の値が入力されているセル範囲または配列を指定します。' },
},
},
FREQUENCY: {
@@ -744,8 +765,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ knownYs: { name: '既知の y', detail: '既知の従属変数の値が入力されているセル範囲または配列を指定します。' },
+ knownXs: { name: '既知の x', detail: '既知の独立変数の値が入力されているセル範囲または配列を指定します。' },
},
},
KURT: {
@@ -988,8 +1009,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '関数に代入する値を指定します。' },
+ mean: { name: '平均', detail: '対象となる分布の算術平均 (相加平均) を指定します。' },
+ standardDev: { name: '標準偏差', detail: '対象となる分布の標準偏差を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
NORM_INV: {
@@ -1002,8 +1025,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: '正規分布における確率を指定します。' },
+ mean: { name: '平均', detail: '対象となる分布の算術平均 (相加平均) を指定します。' },
+ standardDev: { name: '標準偏差', detail: '対象となる分布の標準偏差を指定します。' },
},
},
NORM_S_DIST: {
@@ -1016,8 +1040,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: '関数に代入する値を指定します。' },
+ cumulative: { name: '累積', detail: '計算に使用する関数の形式を論理値で指定します。 関数形式に TRUE を指定すると累積分布関数の値が計算され、FALSE を指定すると確率密度関数の値が計算されます。' },
},
},
NORM_S_INV: {
@@ -1030,8 +1054,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '確率', detail: '正規分布における確率を指定します。' },
},
},
PEARSON: {
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/vi-VN.ts b/packages/sheets-formula/src/locale/function-list/statistical/vi-VN.ts
index f653ba5a09..eb46dd9026 100644
--- a/packages/sheets-formula/src/locale/function-list/statistical/vi-VN.ts
+++ b/packages/sheets-formula/src/locale/function-list/statistical/vi-VN.ts
@@ -99,8 +99,12 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ x: { name: 'số', detail: 'Giá trị được sử dụng để tính toán hàm của nó, giữa giá trị giới hạn dưới và giá trị giới hạn trên.' },
+ alpha: { name: 'alpha', detail: 'Tham số đầu tiên của phân phối.' },
+ beta: { name: 'beta', detail: 'Tham số thứ hai của phân phối.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu tích lũy là TRUE, hàm BETA.DIST trả về hàm phân bố tích lũy; nếu FALSE, nó trả về hàm mật độ xác suất.' },
+ A: { name: 'giới hạn dưới', detail: 'Giới hạn dưới của hàm, giá trị mặc định là 0.' },
+ B: { name: 'giới hạn trên', detail: 'Giới hạn trên của hàm, giá trị mặc định là 1.' },
},
},
BETA_INV: {
@@ -113,8 +117,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ probability: { name: 'xác suất', detail: 'Xác suất gắn với phân bố beta.' },
+ alpha: { name: 'alpha', detail: 'Tham số đầu tiên của phân phối.' },
+ beta: { name: 'beta', detail: 'Tham số thứ hai của phân phối.' },
+ A: { name: 'giới hạn dưới', detail: 'Giới hạn dưới của hàm, giá trị mặc định là 0.' },
+ B: { name: 'giới hạn trên', detail: 'Giới hạn trên của hàm, giá trị mặc định là 1.' },
},
},
BINOM_DIST: {
@@ -127,8 +134,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ numberS: { name: 'số lần thành công', detail: 'Số lần thành công trong các phép thử.' },
+ trials: { name: 'số phép thử', detail: 'Số phép thử độc lập.' },
+ probabilityS: { name: 'xác suất thành công', detail: 'Xác suất thành công của mỗi phép thử.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu tích lũy là TRUE, hàm BINOM.DIST trả về hàm phân bố tích lũy; nếu FALSE, nó trả về hàm mật độ xác suất.' },
},
},
BINOM_DIST_RANGE: {
@@ -141,8 +150,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ trials: { name: 'số phép thử', detail: 'Số phép thử độc lập.' },
+ probabilityS: { name: 'xác suất thành công', detail: 'Xác suất thành công của mỗi phép thử.' },
+ numberS: { name: 'số lần thành công', detail: 'Số lần thành công trong các phép thử.' },
+ numberS2: { name: 'Số lần thành công tối đa', detail: 'Nếu được cung cấp, trả về xác suất số lần thử thành công nằm trong khoảng từ số lần thành công đến số lần thành công tối đa.' },
},
},
BINOM_INV: {
@@ -155,13 +166,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ trials: { name: 'số phép thử', detail: 'Số phép thử Bernoulli.' },
+ probabilityS: { name: 'xác suất thành công', detail: 'Xác suất thành công của mỗi phép thử.' },
+ alpha: { name: 'xác suất mục tiêu', detail: 'Giá trị tiêu chí.' },
},
},
CHISQ_DIST: {
- description: 'Trả về hàm mật độ xác suất tích lũy beta',
- abstract: 'Trả về hàm mật độ xác suất tích lũy beta',
+ description: 'Trả về xác suất của vế trái của phân bố χ2.',
+ abstract: 'Trả về xác suất của vế trái của phân bố χ2.',
links: [
{
title: 'Hướng dẫn',
@@ -169,13 +181,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ x: { name: 'số', detail: 'Giái trị bạn muốn đánh giá phân phối.' },
+ degFreedom: { name: 'bậc tự do', detail: 'Số bậc tự do.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu lũy tích là ĐÚNG thì CHISQ.DIST trả về hàm phân bố lũy tích; nếu SAI, nó trả về hàm mật độ xác suất.' },
},
},
CHISQ_DIST_RT: {
- description: 'Trả về xác suất đuôi đơn của phân phối χ2',
- abstract: 'Trả về xác suất đuôi đơn của phân phối χ2',
+ description: 'Trả về xác suất bên phải của phân bố χ2.',
+ abstract: 'Trả về xác suất bên phải của phân bố χ2.',
links: [
{
title: 'Hướng dẫn',
@@ -183,13 +196,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ x: { name: 'số', detail: 'Giái trị bạn muốn đánh giá phân phối.' },
+ degFreedom: { name: 'bậc tự do', detail: 'Số bậc tự do.' },
},
},
CHISQ_INV: {
- description: 'Trả về hàm mật độ xác suất tích lũy beta',
- abstract: 'Trả về hàm mật độ xác suất tích lũy beta',
+ description: 'Trả về hàm nghịch đảo của xác suất ở đuôi trái của phân bố χ2.',
+ abstract: 'Trả về hàm nghịch đảo của xác suất ở đuôi trái của phân bố χ2.',
links: [
{
title: 'Hướng dẫn',
@@ -197,13 +210,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ probability: { name: 'xác suất', detail: 'Xác suất liên quan đến phân phối χ2.' },
+ degFreedom: { name: 'bậc tự do', detail: 'Số bậc tự do.' },
},
},
CHISQ_INV_RT: {
- description: 'Trả về hàm nghịch đảo xác suất đuôi của phân phối χ2',
- abstract: 'Trả về hàm nghịch đảo xác suất đuôi của phân phối χ2',
+ description: 'Trả về hàm nghịch đảo của xác suất ở đuôi bên phải của phân bố χ2.',
+ abstract: 'Trả về hàm nghịch đảo của xác suất ở đuôi bên phải của phân bố χ2.',
links: [
{
title: 'Hướng dẫn',
@@ -211,8 +224,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ probability: { name: 'xác suất', detail: 'Xác suất liên quan đến phân phối χ2.' },
+ degFreedom: { name: 'bậc tự do', detail: 'Số bậc tự do.' },
},
},
CHISQ_TEST: {
@@ -225,13 +238,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ actualRange: { name: 'phạm vi quan sát', detail: 'Phạm vi dữ liệu chứa các quan sát để kiểm thử đối với các giá trị dự kiến.' },
+ expectedRange: { name: 'phạm vi dự kiến', detail: 'Phạm vi dữ liệu chứa tỷ lệ của phép nhân tổng hàng và tổng cột với tổng cộng.' },
},
},
CONFIDENCE_NORM: {
- description: 'Trả về khoảng tin cậy của giá trị trung bình tổng thể',
- abstract: 'Trả về khoảng tin cậy của giá trị trung bình tổng thể',
+ description: 'Trả về khoảng tin cậy của trung bình tổng thể, bằng cách dùng phân bố chuẩn hóa.',
+ abstract: 'Trả về khoảng tin cậy của trung bình tổng thể, bằng cách dùng phân bố chuẩn hóa.',
links: [
{
title: 'Dạy học',
@@ -239,8 +252,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: 'Mức quan trọng được dùng để tính toán mức tin cậy. Mức tin cậy bằng 100*(1 - alpha)%, hay nói cách khác, alpha 0,05 cho biết mức tin cậy 95 phần trăm.' },
+ standardDev: { name: 'Độ lệch chuẩn tổng', detail: 'Độ lệch chuẩn tổng thể cho phạm vi dữ liệu và được giả định là đã được xác định.' },
+ size: { name: 'cỡ mẫu', detail: 'Cỡ mẫu.' },
},
},
CONFIDENCE_T: {
@@ -253,8 +267,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ alpha: { name: 'alpha', detail: 'Mức quan trọng được dùng để tính toán mức tin cậy. Mức tin cậy bằng 100*(1 - alpha)%, hay nói cách khác, alpha 0,05 cho biết mức tin cậy 95 phần trăm.' },
+ standardDev: { name: 'Độ lệch chuẩn tổng', detail: 'Độ lệch chuẩn tổng thể cho phạm vi dữ liệu và được giả định là đã được xác định.' },
+ size: { name: 'cỡ mẫu', detail: 'Cỡ mẫu.' },
},
},
CORREL: {
@@ -267,8 +282,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'số thứ nhất', detail: '' },
- number2: { name: 'số thứ hai', detail: '' },
+ array1: { name: 'mảng 1', detail: 'Phạm vi giá trị ô đầu tiên.' },
+ array2: { name: 'mảng 2', detail: 'Phạm vi giá trị ô thứ hai.' },
},
},
COUNT: {
@@ -355,6 +370,208 @@ export default {
criteria2: { name: 'tiêu chí 2', detail: 'Điều kiện liên kết bổ sung. Có thể nhập tối đa 127 điều kiện.' },
},
},
+ COVARIANCE_P: {
+ description: 'Trả về hiệp phương sai của tập hợp, trung bình tích của các độ lệnh cho mỗi cặp điểm dữ liệu trong hai tập dữ liệu.',
+ abstract: 'Trả về hiệp phương sai của tập hợp',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/covariance-p-%E5%87%BD%E6%95%B0-6f0e1e6d-956d-4e4b-9943-cfef0bf9edfc',
+ },
+ ],
+ functionParameter: {
+ array1: { name: 'mảng 1', detail: 'Phạm vi giá trị ô đầu tiên.' },
+ array2: { name: 'mảng 2', detail: 'Phạm vi giá trị ô thứ hai.' },
+ },
+ },
+ COVARIANCE_S: {
+ description: 'Trả về hiệp phương sai mẫu, trung bình tích của các độ lệnh cho mỗi cặp điểm dữ liệu trong hai tập dữ liệu.',
+ abstract: 'Trả về hiệp phương sai mẫu',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/covariance-s-%E5%87%BD%E6%95%B0-0a539b74-7371-42aa-a18f-1f5320314977',
+ },
+ ],
+ functionParameter: {
+ array1: { name: 'mảng 1', detail: 'Phạm vi giá trị ô đầu tiên.' },
+ array2: { name: 'mảng 2', detail: 'Phạm vi giá trị ô thứ hai.' },
+ },
+ },
+ DEVSQ: {
+ description: 'Trả về tổng độ lệch bình phương',
+ abstract: 'Trả về tổng độ lệch bình phương',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/devsq-%E5%87%BD%E6%95%B0-8b739616-8376-4df5-8bd0-cfe0a6caf444',
+ },
+ ],
+ functionParameter: {
+ number1: { name: 'số 1', detail: 'Tham số thứ nhất mà bạn muốn tính tổng bình phương độ lệch.' },
+ number2: { name: 'số 2', detail: 'Tham số từ 2 đến 255 mà bạn muốn tính tổng bình phương độ lệch.' },
+ },
+ },
+ EXPON_DIST: {
+ description: 'Trả về phân bố hàm mũ.',
+ abstract: 'Trả về phân bố hàm mũ.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/expon-dist-%E5%87%BD%E6%95%B0-4c12ae24-e563-4155-bf3e-8b78b6ae140e',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'số', detail: 'Giái trị bạn muốn đánh giá phân phối.' },
+ lambda: { name: 'lambda', detail: 'Giá trị tham số.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu lũy tích là ĐÚNG thì EXPON.DIST trả về hàm phân bố lũy tích; nếu SAI, nó trả về hàm mật độ xác suất.' },
+ },
+ },
+ F_DIST: {
+ description: 'Trả về phân bố xác suất F.',
+ abstract: 'Trả về phân bố xác suất F.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/f-dist-%E5%87%BD%E6%95%B0-a887efdc-7c8e-46cb-a74a-f884cd29b25d',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'số', detail: 'Giá trị để đánh giá hàm.' },
+ degFreedom1: { name: 'bậc tự do ở tử số', detail: 'Bậc tự do ở tử số.' },
+ degFreedom2: { name: 'bậc tự do ở mẫu số.', detail: 'Bậc tự do ở mẫu số.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu lũy tích là ĐÚNG thì F.DIST trả về hàm phân bố lũy tích; nếu SAI, nó trả về hàm mật độ xác suất.' },
+ },
+ },
+ F_DIST_RT: {
+ description: 'Trả về phân bố xác suất F (đuôi bên phải)',
+ abstract: 'Trả về phân bố xác suất F (đuôi bên phải)',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/f-dist-rt-%E5%87%BD%E6%95%B0-d74cbb00-6017-4ac9-b7d7-6049badc0520',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'số', detail: 'Giá trị để đánh giá hàm.' },
+ degFreedom1: { name: 'bậc tự do ở tử số', detail: 'Bậc tự do ở tử số.' },
+ degFreedom2: { name: 'bậc tự do ở mẫu số.', detail: 'Bậc tự do ở mẫu số.' },
+ },
+ },
+ F_INV: {
+ description: 'Trả về giá trị đảo của phân bố xác suất F.',
+ abstract: 'Trả về giá trị đảo của phân bố xác suất F.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/f-inv-%E5%87%BD%E6%95%B0-0dda0cf9-4ea0-42fd-8c3c-417a1ff30dbe',
+ },
+ ],
+ functionParameter: {
+ probability: { name: 'xác suất', detail: 'Xác suất gắn với phân bố lũy tích F.' },
+ degFreedom1: { name: 'bậc tự do ở tử số', detail: 'Bậc tự do ở tử số.' },
+ degFreedom2: { name: 'bậc tự do ở mẫu số.', detail: 'Bậc tự do ở mẫu số.' },
+ },
+ },
+ F_INV_RT: {
+ description: 'Trả về giá trị đảo của phân bố xác suất F (đuôi bên phải).',
+ abstract: 'Trả về giá trị đảo của phân bố xác suất F (đuôi bên phải).',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/f-inv-rt-%E5%87%BD%E6%95%B0-d371aa8f-b0b1-40ef-9cc2-496f0693ac00',
+ },
+ ],
+ functionParameter: {
+ probability: { name: 'xác suất', detail: 'Xác suất gắn với phân bố lũy tích F.' },
+ degFreedom1: { name: 'bậc tự do ở tử số', detail: 'Bậc tự do ở tử số.' },
+ degFreedom2: { name: 'bậc tự do ở mẫu số.', detail: 'Bậc tự do ở mẫu số.' },
+ },
+ },
+ F_TEST: {
+ description: 'Trả về kết quả của kiểm tra F-test',
+ abstract: 'Trả về kết quả của kiểm tra F-test',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/f-test-%E5%87%BD%E6%95%B0-100a59e7-4108-46f8-8443-78ffacb6c0a7',
+ },
+ ],
+ functionParameter: {
+ array1: { name: 'mảng 1', detail: 'Mảng thứ nhất của phạm vi dữ liệu.' },
+ array2: { name: 'mảng 2', detail: 'Mảng thứ hai của phạm vi dữ liệu.' },
+ },
+ },
+ FISHER: {
+ description: 'Trả về phép biến đổi Fisher tại x.',
+ abstract: 'Trả về phép biến đổi Fisher tại x.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/fisher-%E5%87%BD%E6%95%B0-d656523c-5076-4f95-b87b-7741bf236c69',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'số', detail: 'Giá trị số mà bạn muốn biến đổi.' },
+ },
+ },
+ FISHERINV: {
+ description: 'Trả về nghịch đảo của phép biến đổi Fisher. ',
+ abstract: 'Trả về nghịch đảo của phép biến đổi Fisher. ',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/fisherinv-%E5%87%BD%E6%95%B0-62504b39-415a-4284-a285-19c8e82f86bb',
+ },
+ ],
+ functionParameter: {
+ y: { name: 'số', detail: 'Giá trị mà bạn muốn thực hiện nghịch đảo của phép biến đổi.' },
+ },
+ },
+ FORECAST: {
+ description: 'Trả về giá trị xu hướng tuyến tính',
+ abstract: 'Trả về giá trị xu hướng tuyến tính',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'x', detail: 'Điểm dữ liệu mà bạn muốn dự đoán một giá trị cho nó.' },
+ knownYs: { name: 'mảng _y', detail: 'Mảng phụ thuộc của mảng hoặc phạm vi dữ liệu.' },
+ knownXs: { name: 'mảng _x', detail: 'Mảng độc lập của mảng hoặc phạm vi dữ liệu.' },
+ },
+ },
+ FORECAST_LINEAR: {
+ description: 'Trả về giá trị tương lai dựa trên giá trị hiện tại',
+ abstract: 'Trả về giá trị tương lai dựa trên giá trị hiện tại',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'x', detail: 'Điểm dữ liệu mà bạn muốn dự đoán một giá trị cho nó.' },
+ knownYs: { name: 'mảng _y', detail: 'Mảng phụ thuộc của mảng hoặc phạm vi dữ liệu.' },
+ knownXs: { name: 'mảng _x', detail: 'Mảng độc lập của mảng hoặc phạm vi dữ liệu.' },
+ },
+ },
+ INTERCEPT: {
+ description: 'Trả về điểm chặn của đường hồi quy tuyến tính',
+ abstract: 'Trả về điểm chặn của đường hồi quy tuyến tính',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/intercept-%E5%87%BD%E6%95%B0-2a9b74e2-9d47-4772-b663-3bca70bf63ef',
+ },
+ ],
+ functionParameter: {
+ knownYs: { name: 'mảng _y', detail: 'Mảng phụ thuộc của mảng hoặc phạm vi dữ liệu.' },
+ knownXs: { name: 'mảng _x', detail: 'Mảng độc lập của mảng hoặc phạm vi dữ liệu.' },
+ },
+ },
MAX: {
description: 'Trả về giá trị lớn nhất trong tập giá trị.',
abstract: 'Trả về giá trị lớn nhất trong tập giá trị.',
@@ -457,6 +674,64 @@ export default {
criteria2: { name: 'tiêu chí 2', detail: 'Điều kiện liên kết bổ sung. Có thể nhập tối đa 127 điều kiện.' },
},
},
+ NORM_DIST: {
+ description: 'Trả về hàm phân phối tích lũy chuẩn',
+ abstract: 'Trả về hàm phân phối tích lũy chuẩn',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/norm-dist-%E5%87%BD%E6%95%B0-edb1cc14-a21c-4e53-839d-8082074c9f8d',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'x', detail: 'Giá trị mà bạn muốn có phân bố của nó.' },
+ mean: { name: 'trung độ số', detail: 'Trung độ số học của phân phối.' },
+ standardDev: { name: 'Độ lệch chuẩn', detail: 'Độ lệch chuẩn của phân phối.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu lũy tích là ĐÚNG thì NORM.DIST trả về hàm phân bố lũy tích; nếu SAI, nó trả về hàm mật độ xác suất.' },
+ },
+ },
+ NORM_INV: {
+ description: 'Trả về hàm nghịch đảo của hàm phân phối tích lũy chuẩn',
+ abstract: 'Trả về hàm nghịch đảo của hàm phân phối tích lũy chuẩn',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/norm-inv-%E5%87%BD%E6%95%B0-54b30935-fee7-493c-bedb-2278a9db7e13',
+ },
+ ],
+ functionParameter: {
+ probability: { name: 'xác suất', detail: 'Một xác suất tương ứng với phân bố chuẩn.' },
+ mean: { name: 'trung độ số', detail: 'Trung độ số học của phân phối.' },
+ standardDev: { name: 'Độ lệch chuẩn', detail: 'Độ lệch chuẩn của phân phối.' },
+ },
+ },
+ NORM_S_DIST: {
+ description: 'Trả về phân bố chuẩn chuẩn hóa',
+ abstract: 'Trả về phân bố chuẩn chuẩn hóa',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/norm-s-dist-%E5%87%BD%E6%95%B0-1e787282-3832-4520-a9ae-bd2a8d99ba88',
+ },
+ ],
+ functionParameter: {
+ z: { name: 'z', detail: 'Giá trị mà bạn muốn có phân bố của nó.' },
+ cumulative: { name: 'tích lũy', detail: 'Một giá trị lô-gic quyết định dạng thức của hàm. Nếu lũy tích là ĐÚNG thì NORM.DIST trả về hàm phân bố lũy tích; nếu SAI, nó trả về hàm mật độ xác suất.' },
+ },
+ },
+ NORM_S_INV: {
+ description: 'Trả về giá trị đảo của phân bố lũy tích chuẩn chuẩn hóa.',
+ abstract: 'Trả về giá trị đảo của phân bố lũy tích chuẩn chuẩn hóa.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/norm-s-inv-%E5%87%BD%E6%95%B0-d6d556b4-ab7f-49cd-b526-5a20918452b1',
+ },
+ ],
+ functionParameter: {
+ probability: { name: 'xác suất', detail: 'Một xác suất tương ứng với phân bố chuẩn.' },
+ },
+ },
RANK_AVG: {
description: 'Trả về thứ hạng của một số trong một danh sách các số',
abstract: 'Trả về thứ hạng của một số trong một danh sách các số',
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts b/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts
index 0dd0b44337..77ff2b3e7b 100644
--- a/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts
+++ b/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts
@@ -111,8 +111,12 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算其函数的值,介于下限值和上限值之间。' },
+ alpha: { name: 'alpha', detail: '分布的第一个参数。' },
+ beta: { name: 'beta', detail: '分布的第二个参数。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。如果为TRUE,则 BETA.DIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
+ A: { name: '下限', detail: '函数的下限,默认值为 0。' },
+ B: { name: '上限', detail: '函数的上限,默认值为 1。' },
},
},
BETA_INV: {
@@ -125,8 +129,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '与 beta 分布相关的概率。' },
+ alpha: { name: 'alpha', detail: '分布的第一个参数。' },
+ beta: { name: 'beta', detail: '分布的第二个参数。' },
+ A: { name: '下限', detail: '函数的下限,默认值为 0。' },
+ B: { name: '上限', detail: '函数的上限,默认值为 1。' },
},
},
BINOM_DIST: {
@@ -139,8 +146,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: '成功次数', detail: '试验的成功次数。' },
+ trials: { name: '试验次数', detail: '独立试验次数。' },
+ probabilityS: { name: '成功概率', detail: '每次试验成功的概率。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。如果为TRUE,则 BINOM.DIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
BINOM_DIST_RANGE: {
@@ -153,8 +162,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '试验次数', detail: '独立试验次数。' },
+ probabilityS: { name: '成功概率', detail: '每次试验成功的概率。' },
+ numberS: { name: '成功次数', detail: '试验的成功次数。' },
+ numberS2: { name: '最大成功次数', detail: '如果提供,则返回成功试验数介于 成功次数 和 最大成功次数 之间的概率。' },
},
},
BINOM_INV: {
@@ -167,13 +178,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '试验次数', detail: '伯努利试验的次数。' },
+ probabilityS: { name: '成功概率', detail: '每次试验成功的概率。' },
+ alpha: { name: '目标概率', detail: '临界值。' },
},
},
CHISQ_DIST: {
- description: '返回累积 beta 概率密度函数',
- abstract: '返回累积 beta 概率密度函数',
+ description: '返回 χ2 分布的左尾概率。',
+ abstract: '返回 χ2 分布的左尾概率。',
links: [
{
title: '教学',
@@ -181,13 +193,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算分布的数值。' },
+ degFreedom: { name: '自由度', detail: '自由度数。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。 如果为 TRUE,则 CHISQ.DIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
CHISQ_DIST_RT: {
- description: '返回 χ2 分布的单尾概率',
- abstract: '返回 χ2 分布的单尾概率',
+ description: '返回 χ2 分布的右尾概率。',
+ abstract: '返回 χ2 分布的右尾概率。',
links: [
{
title: '教学',
@@ -195,13 +208,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算分布的数值。' },
+ degFreedom: { name: '自由度', detail: '自由度数。' },
},
},
CHISQ_INV: {
- description: '返回累积 beta 概率密度函数',
- abstract: '返回累积 beta 概率密度函数',
+ description: '返回 χ2 分布的左尾概率的反函数。',
+ abstract: '返回 χ2 分布的左尾概率的反函数。',
links: [
{
title: '教学',
@@ -209,13 +222,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '与 χ2 分布相关联的概率。' },
+ degFreedom: { name: '自由度', detail: '自由度数。' },
},
},
CHISQ_INV_RT: {
- description: '返回 χ2 分布的单尾概率的反函数',
- abstract: '返回 χ2 分布的单尾概率的反函数',
+ description: '返回 χ2 分布的右尾概率的反函数。',
+ abstract: '返回 χ2 分布的右尾概率的反函数。',
links: [
{
title: '教学',
@@ -223,8 +236,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '与 χ2 分布相关联的概率。' },
+ degFreedom: { name: '自由度', detail: '自由度数。' },
},
},
CHISQ_TEST: {
@@ -237,13 +250,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: '观察范围', detail: '包含观察值的数据区域,用于检验预期值。' },
+ expectedRange: { name: '预期范围', detail: '包含行列汇总的乘积与总计值之比率的数据区域。' },
},
},
CONFIDENCE_NORM: {
- description: '返回总体平均值的置信区间',
- abstract: '返回总体平均值的置信区间',
+ description: '使用正态分布返回总体平均值的置信区间。',
+ abstract: '使用正态分布返回总体平均值的置信区间。',
links: [
{
title: '教学',
@@ -251,8 +264,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '用来计算置信水平的显著性水平。 置信水平等于 100*(1 - alpha)%,亦即,如果 alpha 为 0.05,则置信水平为 95%。' },
+ standardDev: { name: '总体标准偏差', detail: '数据区域的总体标准偏差,假定为已知。' },
+ size: { name: '样本大小', detail: '样本大小。' },
},
},
CONFIDENCE_T: {
@@ -265,8 +279,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '用来计算置信水平的显著性水平。 置信水平等于 100*(1 - alpha)%,亦即,如果 alpha 为 0.05,则置信水平为 95%。' },
+ standardDev: { name: '总体标准偏差', detail: '数据区域的总体标准偏差,假定为已知。' },
+ size: { name: '样本大小', detail: '样本大小。' },
},
},
CORREL: {
@@ -279,8 +294,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '数组1', detail: '第一个单元格值区域。' },
+ array2: { name: '数组2', detail: '第二个单元格值区域。' },
},
},
COUNT: {
@@ -368,8 +383,8 @@ export default {
},
},
COVARIANCE_P: {
- description: '返回协方差(成对偏差乘积的平均值)',
- abstract: '返回协方差(成对偏差乘积的平均值)',
+ description: '返回总体协方差,即两个数据集中每对数据点的偏差乘积的平均值。',
+ abstract: '返回总体协方差',
links: [
{
title: '教学',
@@ -377,13 +392,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '数组1', detail: '第一个单元格值区域。' },
+ array2: { name: '数组2', detail: '第二个单元格值区域。' },
},
},
COVARIANCE_S: {
- description: '返回样本协方差,即两个数据集中每对数据点的偏差乘积的平均值',
- abstract: '返回样本协方差,即两个数据集中每对数据点的偏差乘积的平均值',
+ description: '返回样本协方差,即两个数据集中每对数据点的偏差乘积的平均值。',
+ abstract: '返回样本协方差',
links: [
{
title: '教学',
@@ -391,8 +406,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '数组1', detail: '第一个单元格值区域。' },
+ array2: { name: '数组2', detail: '第二个单元格值区域。' },
},
},
DEVSQ: {
@@ -405,8 +420,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数值1', detail: '用于计算偏差平方和的第 1 个参数。' },
+ number2: { name: '数值2', detail: '用于计算偏差平方和的第 2 到 255 个参数。' },
},
},
EXPON_DIST: {
@@ -419,8 +434,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算分布的数值。' },
+ lambda: { name: 'lambda', detail: '参数值。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。 如果为 TRUE,则 EXPON.DIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
F_DIST: {
@@ -433,13 +449,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算函数的值。' },
+ degFreedom1: { name: '分子自由度', detail: '分子自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '分母自由度。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。 如果为 TRUE,则 F.DIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
F_DIST_RT: {
- description: '返回 F 概率分布',
- abstract: '返回 F 概率分布',
+ description: '返回 F 概率分布(右尾)',
+ abstract: '返回 F 概率分布(右尾)',
links: [
{
title: '教学',
@@ -447,8 +465,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用来计算函数的值。' },
+ degFreedom1: { name: '分子自由度', detail: '分子自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '分母自由度。' },
},
},
F_INV: {
@@ -461,13 +480,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: 'F 累积分布的概率值。' },
+ degFreedom1: { name: '分子自由度', detail: '分子自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '分母自由度。' },
},
},
F_INV_RT: {
- description: '返回 F 概率分布的反函数',
- abstract: '返回 F 概率分布的反函数',
+ description: '返回 F 概率分布(右尾)的反函数',
+ abstract: '返回 F 概率分布(右尾)的反函数',
links: [
{
title: '教学',
@@ -475,8 +495,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: 'F 累积分布的概率值。' },
+ degFreedom1: { name: '分子自由度', detail: '分子自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '分母自由度。' },
},
},
F_TEST: {
@@ -489,8 +510,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '数组1', detail: '第一个数据数组或数据范围。' },
+ array2: { name: '数组2', detail: '第二个数据数组或数据范围。' },
},
},
FISHER: {
@@ -503,8 +524,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '数值', detail: '要对其进行变换的数值。' },
},
},
FISHERINV: {
@@ -517,8 +537,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ y: { name: '数值', detail: '要对其进行逆变换的数值。' },
},
},
FORECAST: {
@@ -531,8 +550,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '需要进行值预测的数据点。' },
+ knownYs: { name: '数据_y', detail: '代表因变量数据的数组或矩阵的范围。' },
+ knownXs: { name: '数据_x', detail: '代表自变量数据的数组或矩阵的范围。' },
},
},
FORECAST_ETS: {
@@ -597,12 +617,13 @@ export default {
links: [
{
title: '教学',
- url: 'https://support.microsoft.com/zh-cn/office/%E9%A2%84%E6%B5%8B%E5%87%BD%E6%95%B0-%E5%8F%82%E8%80%83-897a2fe9-6595-4680-a0b0-93e0308d5f6e#_FORECAST.LINEAR',
+ url: 'https://support.microsoft.com/zh-cn/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '需要进行值预测的数据点。' },
+ knownYs: { name: '数据_y', detail: '代表因变量数据的数组或矩阵的范围。' },
+ knownXs: { name: '数据_x', detail: '代表自变量数据的数组或矩阵的范围。' },
},
},
FREQUENCY: {
@@ -769,8 +790,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ knownYs: { name: '数据_y', detail: '代表因变量数据的数组或矩阵的范围。' },
+ knownXs: { name: '数据_x', detail: '代表自变量数据的数组或矩阵的范围。' },
},
},
KURT: {
@@ -1025,8 +1046,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '需要计算其分布的数值。' },
+ mean: { name: '平均值', detail: '分布的算术平均值。' },
+ standardDev: { name: '标准偏差', detail: '分布的标准偏差。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。 如果为 TRUE,则 NORM.DIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
NORM_INV: {
@@ -1039,8 +1062,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '对应于正态分布的概率。' },
+ mean: { name: '平均值', detail: '分布的算术平均值。' },
+ standardDev: { name: '标准偏差', detail: '分布的标准偏差。' },
},
},
NORM_S_DIST: {
@@ -1053,8 +1077,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: '需要计算其分布的数值。' },
+ cumulative: { name: '累积', detail: '决定函数形式的逻辑值。 如果为 TRUE,则 NORM.DIST 返回累积分布函数;如果为 FALSE,则返回概率密度函数。' },
},
},
NORM_S_INV: {
@@ -1067,8 +1091,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '概率', detail: '对应于正态分布的概率。' },
},
},
PEARSON: {
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/zh-TW.ts b/packages/sheets-formula/src/locale/function-list/statistical/zh-TW.ts
index 873ec15433..fb7c4510a1 100644
--- a/packages/sheets-formula/src/locale/function-list/statistical/zh-TW.ts
+++ b/packages/sheets-formula/src/locale/function-list/statistical/zh-TW.ts
@@ -111,8 +111,12 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '用來計算其函數的值,介於下限值和上限值之間。' },
+ alpha: { name: 'alpha', detail: '分佈的第一個參數。' },
+ beta: { name: 'beta', detail: '分佈的第二個參數。' },
+ cumulative: { name: '累積', detail: '決定函數形式的邏輯值。如果為 TRUE,則 BETA.DIST 傳回累積分佈函數;如果為 FALSE,則傳回機率密度函數。' },
+ A: { name: '下限', detail: '函數的下限,預設值為 0。' },
+ B: { name: '上限', detail: '函數的上限,預設值為 1。' },
},
},
BETA_INV: {
@@ -125,8 +129,11 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是 beta 分佈的相關機率。' },
+ alpha: { name: 'alpha', detail: '分佈的第一個參數。' },
+ beta: { name: 'beta', detail: '分佈的第二個參數。' },
+ A: { name: '下限', detail: '函數的下限,預設值為 0。' },
+ B: { name: '上限', detail: '函數的上限,預設值為 1。' },
},
},
BINOM_DIST: {
@@ -139,8 +146,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numberS: { name: '成功次數', detail: '為實驗的成功次數。' },
+ trials: { name: '實驗次數', detail: '為獨立實驗的次數。' },
+ probabilityS: { name: '成功機率', detail: '每一次實驗的成功機率。' },
+ cumulative: { name: '累積', detail: '決定函數形式的邏輯值。如果為 TRUE,則 BINOM.DIST 傳回累積分佈函數;如果為 FALSE,則傳回機率密度函數。' },
},
},
BINOM_DIST_RANGE: {
@@ -153,8 +162,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '實驗次數', detail: '為獨立實驗的次數。' },
+ probabilityS: { name: '成功機率', detail: '每一次實驗的成功機率。' },
+ numberS: { name: '成功次數', detail: '為實驗的成功次數。' },
+ numberS2: { name: '最大成功次數', detail: '如果提供,會傳回成功試驗次數落在 成功次數 和 最大成功次數 之間的機率。' },
},
},
BINOM_INV: {
@@ -167,13 +178,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ trials: { name: '實驗次數', detail: '伯努利實驗的次數。' },
+ probabilityS: { name: '成功機率', detail: '每一次實驗的成功機率。' },
+ alpha: { name: '目標機率', detail: '這是臨界值。' },
},
},
CHISQ_DIST: {
- description: '傳回累積 beta 機率密度函數',
- abstract: '返回累積 beta 機率密度函數',
+ description: '返回 χ2 分佈的左尾機率。',
+ abstract: '返回 χ2 分佈的左尾機率。',
links: [
{
title: '教導',
@@ -181,13 +193,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用來評估分佈的值。' },
+ degFreedom: { name: '自由度', detail: '這是自由度。' },
+ cumulative: { name: '累積', detail: ' 這是決定函數形式的邏輯值。 如果為 TRUE,CHISQ.DIST 會傳回累積分佈函數;如果為 FALSE,則會傳回機率密度函數。' },
},
},
CHISQ_DIST_RT: {
- description: '傳回 χ2 分佈的單尾機率',
- abstract: '傳回 χ2 分佈的單尾機率',
+ description: '傳回 χ2 分佈的右尾機率。',
+ abstract: '傳回 χ2 分佈的右尾機率。',
links: [
{
title: '教導',
@@ -195,13 +208,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用來評估分佈的值。' },
+ degFreedom: { name: '自由度', detail: '這是自由度。' },
},
},
CHISQ_INV: {
- description: '傳回累積 beta 機率密度函數',
- abstract: '返回累積 beta 機率密度函數',
+ description: '返回 χ2 分佈的左尾機率的反函數值。',
+ abstract: '返回 χ2 分佈的左尾機率的反函數值。',
links: [
{
title: '教導',
@@ -209,13 +222,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是與 χ2 分佈相關聯的機率。' },
+ degFreedom: { name: '自由度', detail: '這是自由度。' },
},
},
CHISQ_INV_RT: {
- description: '傳回 χ2 分佈的單尾機率的反函數',
- abstract: '傳回 χ2 分佈的單尾機率的反函數',
+ description: '傳回 χ2 分佈的右尾機率的反函數值。',
+ abstract: '傳回 χ2 分佈的右尾機率的反函數值。',
links: [
{
title: '教導',
@@ -223,8 +236,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是與 χ2 分佈相關聯的機率。' },
+ degFreedom: { name: '自由度', detail: '這是自由度。' },
},
},
CHISQ_TEST: {
@@ -237,13 +250,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ actualRange: { name: '觀察範圍', detail: '這是觀察值範圍,用來檢定預期值。' },
+ expectedRange: { name: '預期範圍', detail: '這是資料範圍,其內容為各欄總和乘各列總和後的值,再除以全部值總和的比率。' },
},
},
CONFIDENCE_NORM: {
- description: '傳回總體平均值的置信區間',
- abstract: '傳回總體平均值的置信區間',
+ description: '使用常態分佈傳回總體平均值的置信區間。',
+ abstract: '使用常態分佈傳回總體平均值的置信區間。',
links: [
{
title: '教導',
@@ -251,8 +264,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '用於計算置信水準的顯著水準。置信水準等於 100*(1 - alpha)%,換句話說,alpha 0.05 表示信賴水準為 95%。' },
+ standardDev: { name: '總體標準差', detail: '假設資料範圍的總體標準差已知。' },
+ size: { name: '樣本大小', detail: '這是樣本大小。' },
},
},
CONFIDENCE_T: {
@@ -265,8 +279,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ alpha: { name: 'alpha', detail: '用於計算置信水準的顯著水準。置信水準等於 100*(1 - alpha)%,換句話說,alpha 0.05 表示信賴水準為 95%。' },
+ standardDev: { name: '總體標準差', detail: '假設資料範圍的總體標準差已知。' },
+ size: { name: '樣本大小', detail: '這是樣本大小。' },
},
},
CORREL: {
@@ -279,8 +294,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '陣列1', detail: '第一個儲存格值範圍。' },
+ array2: { name: '陣列2', detail: '第二個儲存格值範圍。' },
},
},
COUNT: {
@@ -367,8 +382,8 @@ export default {
},
},
COVARIANCE_P: {
- description: '傳回協方差(成對偏差乘積的平均值)',
- abstract: '傳回協方差(成對偏差乘積的平均值)',
+ description: '傳回總體協方差,即兩個資料集中每對資料點的偏差乘積的平均值。',
+ abstract: '傳回總體協方差',
links: [
{
title: '教導',
@@ -376,13 +391,13 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '陣列1', detail: '第一個儲存格值範圍。' },
+ array2: { name: '陣列2', detail: '第二個儲存格值範圍。' },
},
},
COVARIANCE_S: {
- description: '傳回樣本協方差,即兩個資料集中每對資料點的偏差乘積的平均值',
- abstract: '傳回樣本協方差,即兩個資料集中每對資料點的偏差乘積的平均值',
+ description: '傳回樣本協方差,即兩個資料集中每對資料點的偏差乘積的平均值。',
+ abstract: '傳回樣本協方差',
links: [
{
title: '教導',
@@ -390,8 +405,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '陣列1', detail: '第一個儲存格值範圍。' },
+ array2: { name: '陣列2', detail: '第二個儲存格值範圍。' },
},
},
DEVSQ: {
@@ -404,8 +419,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '數值1', detail: '這是要計算平方差之總和的第 1 個引數。' },
+ number2: { name: '數值2', detail: '這是要計算平方差之總和的第 2 到 255 個引數。' },
},
},
EXPON_DIST: {
@@ -418,8 +433,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用來評估分佈的值。' },
+ lambda: { name: 'lambda', detail: '這是參數值。' },
+ cumulative: { name: '累積', detail: ' 這是決定函數形式的邏輯值。 如果為 TRUE,EXPON.DIST 會傳回累積分佈函數;如果為 FALSE,則會傳回機率密度函數。' },
},
},
F_DIST: {
@@ -432,13 +448,15 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用於評估函數的值。' },
+ degFreedom1: { name: '分子自由度', detail: '這是分子的自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '這是分母的自由度。' },
+ cumulative: { name: '累積', detail: ' 這是決定函數形式的邏輯值。 如果為 TRUE,F.DIST 會傳回累積分佈函數;如果為 FALSE,則會傳回機率密度函數。' },
},
},
F_DIST_RT: {
- description: '返回 F 機率分佈',
- abstract: '返回 F 機率分佈',
+ description: '返回 F 機率分佈(右尾)',
+ abstract: '返回 F 機率分佈(右尾)',
links: [
{
title: '教導',
@@ -446,8 +464,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '值', detail: '這是用於評估函數的值。' },
+ degFreedom1: { name: '分子自由度', detail: '這是分子的自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '這是分母的自由度。' },
},
},
F_INV: {
@@ -460,13 +479,14 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: 'F 累積分佈相關的機率' },
+ degFreedom1: { name: '分子自由度', detail: '這是分子的自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '這是分母的自由度。' },
},
},
F_INV_RT: {
- description: '傳回 F 機率分佈的反函數',
- abstract: '傳回 F 機率分佈的反函數',
+ description: '傳回 F 機率分佈(右尾)的反函數',
+ abstract: '傳回 F 機率分佈(右尾)的反函數',
links: [
{
title: '教導',
@@ -474,8 +494,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: 'F 累積分佈相關的機率' },
+ degFreedom1: { name: '分子自由度', detail: '這是分子的自由度。' },
+ degFreedom2: { name: '分母自由度', detail: '這是分母的自由度。' },
},
},
F_TEST: {
@@ -488,8 +509,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '陣列1', detail: '這是第一個陣列或資料範圍。' },
+ array2: { name: '陣列2', detail: '這是第一個陣列或資料範圍。' },
},
},
FISHER: {
@@ -502,8 +523,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: '數值', detail: '這是要轉換的數值。' },
},
},
FISHERINV: {
@@ -516,8 +536,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ y: { name: '數值', detail: '這是要執行反轉換的數值。' },
},
},
FORECAST: {
@@ -526,12 +545,13 @@ export default {
links: [
{
title: '教導',
- url: 'https://support.microsoft.com/zh-tw/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892 -94e4-7ad38bbeda99',
+ url: 'https://support.microsoft.com/zh-tw/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '這是要預測值的資料點。' },
+ knownYs: { name: '陣列_y', detail: '代表因變數資料的陣列或矩陣的範圍。' },
+ knownXs: { name: '陣列_x', detail: '代表自變數資料的陣列或矩陣的範圍。' },
},
},
FORECAST_ETS: {
@@ -597,12 +617,13 @@ export default {
links: [
{
title: '教導',
- url: 'https://support.microsoft.com/zh-tw/office/%E9%A2%84%E6%B5%8B%E5%87%BD%E6%95%B0-%E5%8F%82 %E8%80%83-897a2fe9-6595-4680-a0b0-93e0308d5f6e#_FORECAST.LINEAR',
+ url: 'https://support.microsoft.com/zh-tw/office/forecast-%E5%92%8C-forecast-linear-%E5%87%BD%E6%95%B0-50ca49c9-7b40-4892-94e4-7ad38bbeda99',
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '這是要預測值的資料點。' },
+ knownYs: { name: '陣列_y', detail: '代表因變數資料的陣列或矩陣的範圍。' },
+ knownXs: { name: '陣列_x', detail: '代表自變數資料的陣列或矩陣的範圍。' },
},
},
FREQUENCY: {
@@ -769,8 +790,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ knownYs: { name: '陣列_y', detail: '代表因變數資料的陣列或矩陣的範圍。' },
+ knownXs: { name: '陣列_x', detail: '代表自變數資料的陣列或矩陣的範圍。' },
},
},
KURT: {
@@ -1025,8 +1046,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '這是您要找出分佈的數值。' },
+ mean: { name: '平均值', detail: '這是分佈的算術平均值。' },
+ standardDev: { name: '標準差', detail: '這是分佈的標準差。' },
+ cumulative: { name: '累積', detail: ' 這是決定函數形式的邏輯值。 如果為 TRUE,NORM.DIST 會傳回累積分佈函數;如果為 FALSE,則會傳回機率密度函數。' },
},
},
NORM_INV: {
@@ -1039,8 +1062,9 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是對應到常態分佈的機率。' },
+ mean: { name: '平均值', detail: '這是分佈的算術平均值。' },
+ standardDev: { name: '標準差', detail: '這是分佈的標準差。' },
},
},
NORM_S_DIST: {
@@ -1053,8 +1077,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ z: { name: 'z', detail: '這是您要找出分佈的數值。' },
+ cumulative: { name: '累積', detail: ' 這是決定函數形式的邏輯值。 如果為 TRUE,NORM.DIST 會傳回累積分佈函數;如果為 FALSE,則會傳回機率密度函數。' },
},
},
NORM_S_INV: {
@@ -1067,8 +1091,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ probability: { name: '機率', detail: '這是對應到常態分佈的機率。' },
},
},
PEARSON: {
diff --git a/packages/sheets-formula/src/services/function-list/compatibility.ts b/packages/sheets-formula/src/services/function-list/compatibility.ts
index f2985adb3f..3700073eba 100644
--- a/packages/sheets-formula/src/services/function-list/compatibility.ts
+++ b/packages/sheets-formula/src/services/function-list/compatibility.ts
@@ -24,19 +24,40 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.BETADIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.BETADIST.functionParameter.number1.name',
- detail: 'formula.functionList.BETADIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETADIST.functionParameter.x.name',
+ detail: 'formula.functionList.BETADIST.functionParameter.x.detail',
+ example: '2',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BETADIST.functionParameter.number2.name',
- detail: 'formula.functionList.BETADIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETADIST.functionParameter.alpha.name',
+ detail: 'formula.functionList.BETADIST.functionParameter.alpha.detail',
+ example: '8',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETADIST.functionParameter.beta.name',
+ detail: 'formula.functionList.BETADIST.functionParameter.beta.detail',
+ example: '10',
require: 1,
repeat: 0,
},
+ {
+ name: 'formula.functionList.BETADIST.functionParameter.A.name',
+ detail: 'formula.functionList.BETADIST.functionParameter.A.detail',
+ example: '1',
+ require: 0,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETADIST.functionParameter.B.name',
+ detail: 'formula.functionList.BETADIST.functionParameter.B.detail',
+ example: '3',
+ require: 0,
+ repeat: 0,
+ },
],
},
{
@@ -46,19 +67,40 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.BETAINV.abstract',
functionParameter: [
{
- name: 'formula.functionList.BETAINV.functionParameter.number1.name',
- detail: 'formula.functionList.BETAINV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETAINV.functionParameter.probability.name',
+ detail: 'formula.functionList.BETAINV.functionParameter.probability.detail',
+ example: '0.685470581',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BETAINV.functionParameter.number2.name',
- detail: 'formula.functionList.BETAINV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETAINV.functionParameter.alpha.name',
+ detail: 'formula.functionList.BETAINV.functionParameter.alpha.detail',
+ example: '8',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETAINV.functionParameter.beta.name',
+ detail: 'formula.functionList.BETAINV.functionParameter.beta.detail',
+ example: '10',
require: 1,
repeat: 0,
},
+ {
+ name: 'formula.functionList.BETAINV.functionParameter.A.name',
+ detail: 'formula.functionList.BETAINV.functionParameter.A.detail',
+ example: '1',
+ require: 0,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETAINV.functionParameter.B.name',
+ detail: 'formula.functionList.BETAINV.functionParameter.B.detail',
+ example: '3',
+ require: 0,
+ repeat: 0,
+ },
],
},
{
@@ -68,16 +110,30 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.BINOMDIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.BINOMDIST.functionParameter.number1.name',
- detail: 'formula.functionList.BINOMDIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOMDIST.functionParameter.numberS.name',
+ detail: 'formula.functionList.BINOMDIST.functionParameter.numberS.detail',
+ example: '6',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BINOMDIST.functionParameter.number2.name',
- detail: 'formula.functionList.BINOMDIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOMDIST.functionParameter.trials.name',
+ detail: 'formula.functionList.BINOMDIST.functionParameter.trials.detail',
+ example: '10',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BINOMDIST.functionParameter.probabilityS.name',
+ detail: 'formula.functionList.BINOMDIST.functionParameter.probabilityS.detail',
+ example: '0.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BINOMDIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.BINOMDIST.functionParameter.cumulative.detail',
+ example: 'false',
require: 1,
repeat: 0,
},
@@ -90,16 +146,16 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.CHIDIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHIDIST.functionParameter.number1.name',
- detail: 'formula.functionList.CHIDIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHIDIST.functionParameter.x.name',
+ detail: 'formula.functionList.CHIDIST.functionParameter.x.detail',
+ example: '0.5',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHIDIST.functionParameter.number2.name',
- detail: 'formula.functionList.CHIDIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHIDIST.functionParameter.degFreedom.name',
+ detail: 'formula.functionList.CHIDIST.functionParameter.degFreedom.detail',
+ example: '1',
require: 1,
repeat: 0,
},
@@ -112,16 +168,16 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.CHIINV.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHIINV.functionParameter.number1.name',
- detail: 'formula.functionList.CHIINV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHIINV.functionParameter.probability.name',
+ detail: 'formula.functionList.CHIINV.functionParameter.probability.detail',
+ example: '0.93',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHIINV.functionParameter.number2.name',
- detail: 'formula.functionList.CHIINV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHIINV.functionParameter.degFreedom.name',
+ detail: 'formula.functionList.CHIINV.functionParameter.degFreedom.detail',
+ example: '1',
require: 1,
repeat: 0,
},
@@ -134,16 +190,16 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.CHITEST.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHITEST.functionParameter.number1.name',
- detail: 'formula.functionList.CHITEST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHITEST.functionParameter.actualRange.name',
+ detail: 'formula.functionList.CHITEST.functionParameter.actualRange.detail',
+ example: '{58,35;11,25;10,23}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHITEST.functionParameter.number2.name',
- detail: 'formula.functionList.CHITEST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHITEST.functionParameter.expectedRange.name',
+ detail: 'formula.functionList.CHITEST.functionParameter.expectedRange.detail',
+ example: '{45.35,47.65;17.56,18.44;16.09,16.91}',
require: 1,
repeat: 0,
},
@@ -156,16 +212,23 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.CONFIDENCE.abstract',
functionParameter: [
{
- name: 'formula.functionList.CONFIDENCE.functionParameter.number1.name',
- detail: 'formula.functionList.CONFIDENCE.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CONFIDENCE.functionParameter.alpha.name',
+ detail: 'formula.functionList.CONFIDENCE.functionParameter.alpha.detail',
+ example: '0.05',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CONFIDENCE.functionParameter.number2.name',
- detail: 'formula.functionList.CONFIDENCE.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CONFIDENCE.functionParameter.standardDev.name',
+ detail: 'formula.functionList.CONFIDENCE.functionParameter.standardDev.detail',
+ example: '2.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.CONFIDENCE.functionParameter.size.name',
+ detail: 'formula.functionList.CONFIDENCE.functionParameter.size.detail',
+ example: '50',
require: 1,
repeat: 0,
},
@@ -178,16 +241,16 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.COVAR.abstract',
functionParameter: [
{
- name: 'formula.functionList.COVAR.functionParameter.number1.name',
- detail: 'formula.functionList.COVAR.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COVAR.functionParameter.array1.name',
+ detail: 'formula.functionList.COVAR.functionParameter.array1.detail',
+ example: '{3,2,4,5,6}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.COVAR.functionParameter.number2.name',
- detail: 'formula.functionList.COVAR.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COVAR.functionParameter.array2.name',
+ detail: 'formula.functionList.COVAR.functionParameter.array2.detail',
+ example: '{9,7,12,15,17}',
require: 1,
repeat: 0,
},
@@ -200,16 +263,23 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.CRITBINOM.abstract',
functionParameter: [
{
- name: 'formula.functionList.CRITBINOM.functionParameter.number1.name',
- detail: 'formula.functionList.CRITBINOM.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CRITBINOM.functionParameter.trials.name',
+ detail: 'formula.functionList.CRITBINOM.functionParameter.trials.detail',
+ example: '6',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CRITBINOM.functionParameter.number2.name',
- detail: 'formula.functionList.CRITBINOM.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CRITBINOM.functionParameter.probabilityS.name',
+ detail: 'formula.functionList.CRITBINOM.functionParameter.probabilityS.detail',
+ example: '0.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.CRITBINOM.functionParameter.alpha.name',
+ detail: 'formula.functionList.CRITBINOM.functionParameter.alpha.detail',
+ example: '0.75',
require: 1,
repeat: 0,
},
@@ -222,16 +292,23 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.EXPONDIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.EXPONDIST.functionParameter.number1.name',
- detail: 'formula.functionList.EXPONDIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.EXPONDIST.functionParameter.x.name',
+ detail: 'formula.functionList.EXPONDIST.functionParameter.x.detail',
+ example: '0.2',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.EXPONDIST.functionParameter.number2.name',
- detail: 'formula.functionList.EXPONDIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.EXPONDIST.functionParameter.lambda.name',
+ detail: 'formula.functionList.EXPONDIST.functionParameter.lambda.detail',
+ example: '10',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.EXPONDIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.EXPONDIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
@@ -244,16 +321,23 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.FDIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.FDIST.functionParameter.number1.name',
- detail: 'formula.functionList.FDIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FDIST.functionParameter.x.name',
+ detail: 'formula.functionList.FDIST.functionParameter.x.detail',
+ example: '15.2069',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.FDIST.functionParameter.number2.name',
- detail: 'formula.functionList.FDIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FDIST.functionParameter.degFreedom1.name',
+ detail: 'formula.functionList.FDIST.functionParameter.degFreedom1.detail',
+ example: '6',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.FDIST.functionParameter.degFreedom2.name',
+ detail: 'formula.functionList.FDIST.functionParameter.degFreedom2.detail',
+ example: '4',
require: 1,
repeat: 0,
},
@@ -266,16 +350,23 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.FINV.abstract',
functionParameter: [
{
- name: 'formula.functionList.FINV.functionParameter.number1.name',
- detail: 'formula.functionList.FINV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FINV.functionParameter.probability.name',
+ detail: 'formula.functionList.FINV.functionParameter.probability.detail',
+ example: '0.01',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.FINV.functionParameter.number2.name',
- detail: 'formula.functionList.FINV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FINV.functionParameter.degFreedom1.name',
+ detail: 'formula.functionList.FINV.functionParameter.degFreedom1.detail',
+ example: '6',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.FINV.functionParameter.degFreedom2.name',
+ detail: 'formula.functionList.FINV.functionParameter.degFreedom2.detail',
+ example: '4',
require: 1,
repeat: 0,
},
@@ -288,16 +379,16 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.FTEST.abstract',
functionParameter: [
{
- name: 'formula.functionList.FTEST.functionParameter.number1.name',
- detail: 'formula.functionList.FTEST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FTEST.functionParameter.array1.name',
+ detail: 'formula.functionList.FTEST.functionParameter.array1.detail',
+ example: '{58,35;11,25;10,23}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.FTEST.functionParameter.number2.name',
- detail: 'formula.functionList.FTEST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FTEST.functionParameter.array2.name',
+ detail: 'formula.functionList.FTEST.functionParameter.array2.detail',
+ example: '{45.35,47.65;17.56,18.44;16.09,16.91}',
require: 1,
repeat: 0,
},
@@ -464,16 +555,30 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.NORMDIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORMDIST.functionParameter.number1.name',
- detail: 'formula.functionList.NORMDIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORMDIST.functionParameter.x.name',
+ detail: 'formula.functionList.NORMDIST.functionParameter.x.detail',
+ example: '42',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.NORMDIST.functionParameter.number2.name',
- detail: 'formula.functionList.NORMDIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORMDIST.functionParameter.mean.name',
+ detail: 'formula.functionList.NORMDIST.functionParameter.mean.detail',
+ example: '40',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.NORMDIST.functionParameter.standardDev.name',
+ detail: 'formula.functionList.NORMDIST.functionParameter.standardDev.detail',
+ example: '1.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.NORMDIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.NORMDIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
@@ -486,16 +591,23 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.NORMINV.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORMINV.functionParameter.number1.name',
- detail: 'formula.functionList.NORMINV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORMINV.functionParameter.probability.name',
+ detail: 'formula.functionList.NORMINV.functionParameter.probability.detail',
+ example: '0.908789',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.NORMINV.functionParameter.number2.name',
- detail: 'formula.functionList.NORMINV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORMINV.functionParameter.mean.name',
+ detail: 'formula.functionList.NORMINV.functionParameter.mean.detail',
+ example: '40',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.NORMINV.functionParameter.standardDev.name',
+ detail: 'formula.functionList.NORMINV.functionParameter.standardDev.detail',
+ example: '1.5',
require: 1,
repeat: 0,
},
@@ -508,16 +620,9 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.NORMSDIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORMSDIST.functionParameter.number1.name',
- detail: 'formula.functionList.NORMSDIST.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.NORMSDIST.functionParameter.number2.name',
- detail: 'formula.functionList.NORMSDIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORMSDIST.functionParameter.z.name',
+ detail: 'formula.functionList.NORMSDIST.functionParameter.z.detail',
+ example: '1.333333',
require: 1,
repeat: 0,
},
@@ -530,16 +635,9 @@ export const FUNCTION_LIST_COMPATIBILITY: IFunctionInfo[] = [
abstract: 'formula.functionList.NORMSINV.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORMSINV.functionParameter.number1.name',
- detail: 'formula.functionList.NORMSINV.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.NORMSINV.functionParameter.number2.name',
- detail: 'formula.functionList.NORMSINV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORMSINV.functionParameter.probability.name',
+ detail: 'formula.functionList.NORMSINV.functionParameter.probability.detail',
+ example: '0.908789',
require: 1,
repeat: 0,
},
diff --git a/packages/sheets-formula/src/services/function-list/statistical.ts b/packages/sheets-formula/src/services/function-list/statistical.ts
index 9e06b40e1c..19df3ea4c8 100644
--- a/packages/sheets-formula/src/services/function-list/statistical.ts
+++ b/packages/sheets-formula/src/services/function-list/statistical.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { IFunctionInfo } from '@univerjs/engine-formula';
import { FUNCTION_NAMES_STATISTICAL, FunctionType } from '@univerjs/engine-formula';
+import type { IFunctionInfo } from '@univerjs/engine-formula';
export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
{
@@ -164,19 +164,47 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.BETA_DIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.BETA_DIST.functionParameter.number1.name',
- detail: 'formula.functionList.BETA_DIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETA_DIST.functionParameter.x.name',
+ detail: 'formula.functionList.BETA_DIST.functionParameter.x.detail',
+ example: '2',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BETA_DIST.functionParameter.number2.name',
- detail: 'formula.functionList.BETA_DIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETA_DIST.functionParameter.alpha.name',
+ detail: 'formula.functionList.BETA_DIST.functionParameter.alpha.detail',
+ example: '8',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETA_DIST.functionParameter.beta.name',
+ detail: 'formula.functionList.BETA_DIST.functionParameter.beta.detail',
+ example: '10',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETA_DIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.BETA_DIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
+ {
+ name: 'formula.functionList.BETA_DIST.functionParameter.A.name',
+ detail: 'formula.functionList.BETA_DIST.functionParameter.A.detail',
+ example: '1',
+ require: 0,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETA_DIST.functionParameter.B.name',
+ detail: 'formula.functionList.BETA_DIST.functionParameter.B.detail',
+ example: '3',
+ require: 0,
+ repeat: 0,
+ },
],
},
{
@@ -186,19 +214,40 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.BETA_INV.abstract',
functionParameter: [
{
- name: 'formula.functionList.BETA_INV.functionParameter.number1.name',
- detail: 'formula.functionList.BETA_INV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETA_INV.functionParameter.probability.name',
+ detail: 'formula.functionList.BETA_INV.functionParameter.probability.detail',
+ example: '0.685470581',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BETA_INV.functionParameter.number2.name',
- detail: 'formula.functionList.BETA_INV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BETA_INV.functionParameter.alpha.name',
+ detail: 'formula.functionList.BETA_INV.functionParameter.alpha.detail',
+ example: '8',
require: 1,
repeat: 0,
},
+ {
+ name: 'formula.functionList.BETA_INV.functionParameter.beta.name',
+ detail: 'formula.functionList.BETA_INV.functionParameter.beta.detail',
+ example: '10',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETA_INV.functionParameter.A.name',
+ detail: 'formula.functionList.BETA_INV.functionParameter.A.detail',
+ example: '1',
+ require: 0,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BETA_INV.functionParameter.B.name',
+ detail: 'formula.functionList.BETA_INV.functionParameter.B.detail',
+ example: '3',
+ require: 0,
+ repeat: 0,
+ },
],
},
{
@@ -208,16 +257,30 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.BINOM_DIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.BINOM_DIST.functionParameter.number1.name',
- detail: 'formula.functionList.BINOM_DIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOM_DIST.functionParameter.numberS.name',
+ detail: 'formula.functionList.BINOM_DIST.functionParameter.numberS.detail',
+ example: '6',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BINOM_DIST.functionParameter.number2.name',
- detail: 'formula.functionList.BINOM_DIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOM_DIST.functionParameter.trials.name',
+ detail: 'formula.functionList.BINOM_DIST.functionParameter.trials.detail',
+ example: '10',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BINOM_DIST.functionParameter.probabilityS.name',
+ detail: 'formula.functionList.BINOM_DIST.functionParameter.probabilityS.detail',
+ example: '0.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BINOM_DIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.BINOM_DIST.functionParameter.cumulative.detail',
+ example: 'false',
require: 1,
repeat: 0,
},
@@ -230,19 +293,33 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.BINOM_DIST_RANGE.abstract',
functionParameter: [
{
- name: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.number1.name',
- detail: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.trials.name',
+ detail: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.trials.detail',
+ example: '60',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.number2.name',
- detail: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.probabilityS.name',
+ detail: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.probabilityS.detail',
+ example: '0.75',
require: 1,
repeat: 0,
},
+ {
+ name: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.numberS.name',
+ detail: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.numberS.detail',
+ example: '45',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.numberS2.name',
+ detail: 'formula.functionList.BINOM_DIST_RANGE.functionParameter.numberS2.detail',
+ example: '50',
+ require: 0,
+ repeat: 0,
+ },
],
},
{
@@ -252,16 +329,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.BINOM_INV.abstract',
functionParameter: [
{
- name: 'formula.functionList.BINOM_INV.functionParameter.number1.name',
- detail: 'formula.functionList.BINOM_INV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOM_INV.functionParameter.trials.name',
+ detail: 'formula.functionList.BINOM_INV.functionParameter.trials.detail',
+ example: '6',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.BINOM_INV.functionParameter.number2.name',
- detail: 'formula.functionList.BINOM_INV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.BINOM_INV.functionParameter.probabilityS.name',
+ detail: 'formula.functionList.BINOM_INV.functionParameter.probabilityS.detail',
+ example: '0.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.BINOM_INV.functionParameter.alpha.name',
+ detail: 'formula.functionList.BINOM_INV.functionParameter.alpha.detail',
+ example: '0.75',
require: 1,
repeat: 0,
},
@@ -274,16 +358,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CHISQ_DIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHISQ_DIST.functionParameter.number1.name',
- detail: 'formula.functionList.CHISQ_DIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_DIST.functionParameter.x.name',
+ detail: 'formula.functionList.CHISQ_DIST.functionParameter.x.detail',
+ example: '0.5',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHISQ_DIST.functionParameter.number2.name',
- detail: 'formula.functionList.CHISQ_DIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_DIST.functionParameter.degFreedom.name',
+ detail: 'formula.functionList.CHISQ_DIST.functionParameter.degFreedom.detail',
+ example: '1',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.CHISQ_DIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.CHISQ_DIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
@@ -296,16 +387,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CHISQ_DIST_RT.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHISQ_DIST_RT.functionParameter.number1.name',
- detail: 'formula.functionList.CHISQ_DIST_RT.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_DIST_RT.functionParameter.x.name',
+ detail: 'formula.functionList.CHISQ_DIST_RT.functionParameter.x.detail',
+ example: '0.5',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHISQ_DIST_RT.functionParameter.number2.name',
- detail: 'formula.functionList.CHISQ_DIST_RT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_DIST_RT.functionParameter.degFreedom.name',
+ detail: 'formula.functionList.CHISQ_DIST_RT.functionParameter.degFreedom.detail',
+ example: '1',
require: 1,
repeat: 0,
},
@@ -318,16 +409,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CHISQ_INV.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHISQ_INV.functionParameter.number1.name',
- detail: 'formula.functionList.CHISQ_INV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_INV.functionParameter.probability.name',
+ detail: 'formula.functionList.CHISQ_INV.functionParameter.probability.detail',
+ example: '0.93',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHISQ_INV.functionParameter.number2.name',
- detail: 'formula.functionList.CHISQ_INV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_INV.functionParameter.degFreedom.name',
+ detail: 'formula.functionList.CHISQ_INV.functionParameter.degFreedom.detail',
+ example: '1',
require: 1,
repeat: 0,
},
@@ -340,16 +431,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CHISQ_INV_RT.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHISQ_INV_RT.functionParameter.number1.name',
- detail: 'formula.functionList.CHISQ_INV_RT.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_INV_RT.functionParameter.probability.name',
+ detail: 'formula.functionList.CHISQ_INV_RT.functionParameter.probability.detail',
+ example: '0.93',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHISQ_INV_RT.functionParameter.number2.name',
- detail: 'formula.functionList.CHISQ_INV_RT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_INV_RT.functionParameter.degFreedom.name',
+ detail: 'formula.functionList.CHISQ_INV_RT.functionParameter.degFreedom.detail',
+ example: '1',
require: 1,
repeat: 0,
},
@@ -362,16 +453,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CHISQ_TEST.abstract',
functionParameter: [
{
- name: 'formula.functionList.CHISQ_TEST.functionParameter.number1.name',
- detail: 'formula.functionList.CHISQ_TEST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_TEST.functionParameter.actualRange.name',
+ detail: 'formula.functionList.CHISQ_TEST.functionParameter.actualRange.detail',
+ example: '{58,35;11,25;10,23}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CHISQ_TEST.functionParameter.number2.name',
- detail: 'formula.functionList.CHISQ_TEST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CHISQ_TEST.functionParameter.expectedRange.name',
+ detail: 'formula.functionList.CHISQ_TEST.functionParameter.expectedRange.detail',
+ example: '{45.35,47.65;17.56,18.44;16.09,16.91}',
require: 1,
repeat: 0,
},
@@ -384,16 +475,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CONFIDENCE_NORM.abstract',
functionParameter: [
{
- name: 'formula.functionList.CONFIDENCE_NORM.functionParameter.number1.name',
- detail: 'formula.functionList.CONFIDENCE_NORM.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CONFIDENCE_NORM.functionParameter.alpha.name',
+ detail: 'formula.functionList.CONFIDENCE_NORM.functionParameter.alpha.detail',
+ example: '0.05',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CONFIDENCE_NORM.functionParameter.number2.name',
- detail: 'formula.functionList.CONFIDENCE_NORM.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CONFIDENCE_NORM.functionParameter.standardDev.name',
+ detail: 'formula.functionList.CONFIDENCE_NORM.functionParameter.standardDev.detail',
+ example: '2.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.CONFIDENCE_NORM.functionParameter.size.name',
+ detail: 'formula.functionList.CONFIDENCE_NORM.functionParameter.size.detail',
+ example: '50',
require: 1,
repeat: 0,
},
@@ -406,16 +504,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CONFIDENCE_T.abstract',
functionParameter: [
{
- name: 'formula.functionList.CONFIDENCE_T.functionParameter.number1.name',
- detail: 'formula.functionList.CONFIDENCE_T.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CONFIDENCE_T.functionParameter.alpha.name',
+ detail: 'formula.functionList.CONFIDENCE_T.functionParameter.alpha.detail',
+ example: '0.05',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CONFIDENCE_T.functionParameter.number2.name',
- detail: 'formula.functionList.CONFIDENCE_T.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CONFIDENCE_T.functionParameter.standardDev.name',
+ detail: 'formula.functionList.CONFIDENCE_T.functionParameter.standardDev.detail',
+ example: '2.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.CONFIDENCE_T.functionParameter.size.name',
+ detail: 'formula.functionList.CONFIDENCE_T.functionParameter.size.detail',
+ example: '50',
require: 1,
repeat: 0,
},
@@ -428,16 +533,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.CORREL.abstract',
functionParameter: [
{
- name: 'formula.functionList.CORREL.functionParameter.number1.name',
- detail: 'formula.functionList.CORREL.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CORREL.functionParameter.array1.name',
+ detail: 'formula.functionList.CORREL.functionParameter.array1.detail',
+ example: '{3,2,4,5,6}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.CORREL.functionParameter.number2.name',
- detail: 'formula.functionList.CORREL.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.CORREL.functionParameter.array2.name',
+ detail: 'formula.functionList.CORREL.functionParameter.array2.detail',
+ example: '{9,7,12,15,17}',
require: 1,
repeat: 0,
},
@@ -569,16 +674,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.COVARIANCE_P.abstract',
functionParameter: [
{
- name: 'formula.functionList.COVARIANCE_P.functionParameter.number1.name',
- detail: 'formula.functionList.COVARIANCE_P.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COVARIANCE_P.functionParameter.array1.name',
+ detail: 'formula.functionList.COVARIANCE_P.functionParameter.array1.detail',
+ example: '{3,2,4,5,6}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.COVARIANCE_P.functionParameter.number2.name',
- detail: 'formula.functionList.COVARIANCE_P.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COVARIANCE_P.functionParameter.array2.name',
+ detail: 'formula.functionList.COVARIANCE_P.functionParameter.array2.detail',
+ example: '{9,7,12,15,17}',
require: 1,
repeat: 0,
},
@@ -591,16 +696,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.COVARIANCE_S.abstract',
functionParameter: [
{
- name: 'formula.functionList.COVARIANCE_S.functionParameter.number1.name',
- detail: 'formula.functionList.COVARIANCE_S.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COVARIANCE_S.functionParameter.array1.name',
+ detail: 'formula.functionList.COVARIANCE_S.functionParameter.array1.detail',
+ example: '{3,2,4,5,6}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.COVARIANCE_S.functionParameter.number2.name',
- detail: 'formula.functionList.COVARIANCE_S.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COVARIANCE_S.functionParameter.array2.name',
+ detail: 'formula.functionList.COVARIANCE_S.functionParameter.array2.detail',
+ example: '{9,7,12,15,17}',
require: 1,
repeat: 0,
},
@@ -615,16 +720,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
{
name: 'formula.functionList.DEVSQ.functionParameter.number1.name',
detail: 'formula.functionList.DEVSQ.functionParameter.number1.detail',
- example: 'A1:A20',
+ example: '1',
require: 1,
repeat: 0,
},
{
name: 'formula.functionList.DEVSQ.functionParameter.number2.name',
detail: 'formula.functionList.DEVSQ.functionParameter.number2.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
+ example: '2',
+ require: 0,
+ repeat: 1,
},
],
},
@@ -635,16 +740,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.EXPON_DIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.EXPON_DIST.functionParameter.number1.name',
- detail: 'formula.functionList.EXPON_DIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.EXPON_DIST.functionParameter.x.name',
+ detail: 'formula.functionList.EXPON_DIST.functionParameter.x.detail',
+ example: '0.2',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.EXPON_DIST.functionParameter.number2.name',
- detail: 'formula.functionList.EXPON_DIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.EXPON_DIST.functionParameter.lambda.name',
+ detail: 'formula.functionList.EXPON_DIST.functionParameter.lambda.detail',
+ example: '10',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.EXPON_DIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.EXPON_DIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
@@ -657,16 +769,30 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.F_DIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.F_DIST.functionParameter.number1.name',
- detail: 'formula.functionList.F_DIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_DIST.functionParameter.x.name',
+ detail: 'formula.functionList.F_DIST.functionParameter.x.detail',
+ example: '15.2069',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.F_DIST.functionParameter.number2.name',
- detail: 'formula.functionList.F_DIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_DIST.functionParameter.degFreedom1.name',
+ detail: 'formula.functionList.F_DIST.functionParameter.degFreedom1.detail',
+ example: '6',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.F_DIST.functionParameter.degFreedom2.name',
+ detail: 'formula.functionList.F_DIST.functionParameter.degFreedom2.detail',
+ example: '4',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.F_DIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.F_DIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
@@ -679,16 +805,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.F_DIST_RT.abstract',
functionParameter: [
{
- name: 'formula.functionList.F_DIST_RT.functionParameter.number1.name',
- detail: 'formula.functionList.F_DIST_RT.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_DIST_RT.functionParameter.x.name',
+ detail: 'formula.functionList.F_DIST_RT.functionParameter.x.detail',
+ example: '15.2069',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.F_DIST_RT.functionParameter.number2.name',
- detail: 'formula.functionList.F_DIST_RT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_DIST_RT.functionParameter.degFreedom1.name',
+ detail: 'formula.functionList.F_DIST_RT.functionParameter.degFreedom1.detail',
+ example: '6',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.F_DIST_RT.functionParameter.degFreedom2.name',
+ detail: 'formula.functionList.F_DIST_RT.functionParameter.degFreedom2.detail',
+ example: '4',
require: 1,
repeat: 0,
},
@@ -701,16 +834,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.F_INV.abstract',
functionParameter: [
{
- name: 'formula.functionList.F_INV.functionParameter.number1.name',
- detail: 'formula.functionList.F_INV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_INV.functionParameter.probability.name',
+ detail: 'formula.functionList.F_INV.functionParameter.probability.detail',
+ example: '0.01',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.F_INV.functionParameter.number2.name',
- detail: 'formula.functionList.F_INV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_INV.functionParameter.degFreedom1.name',
+ detail: 'formula.functionList.F_INV.functionParameter.degFreedom1.detail',
+ example: '6',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.F_INV.functionParameter.degFreedom2.name',
+ detail: 'formula.functionList.F_INV.functionParameter.degFreedom2.detail',
+ example: '4',
require: 1,
repeat: 0,
},
@@ -723,16 +863,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.F_INV_RT.abstract',
functionParameter: [
{
- name: 'formula.functionList.F_INV_RT.functionParameter.number1.name',
- detail: 'formula.functionList.F_INV_RT.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_INV_RT.functionParameter.probability.name',
+ detail: 'formula.functionList.F_INV_RT.functionParameter.probability.detail',
+ example: '0.01',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.F_INV_RT.functionParameter.number2.name',
- detail: 'formula.functionList.F_INV_RT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_INV_RT.functionParameter.degFreedom1.name',
+ detail: 'formula.functionList.F_INV_RT.functionParameter.degFreedom1.detail',
+ example: '6',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.F_INV_RT.functionParameter.degFreedom2.name',
+ detail: 'formula.functionList.F_INV_RT.functionParameter.degFreedom2.detail',
+ example: '4',
require: 1,
repeat: 0,
},
@@ -745,16 +892,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.F_TEST.abstract',
functionParameter: [
{
- name: 'formula.functionList.F_TEST.functionParameter.number1.name',
- detail: 'formula.functionList.F_TEST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_TEST.functionParameter.array1.name',
+ detail: 'formula.functionList.F_TEST.functionParameter.array1.detail',
+ example: '{58,35;11,25;10,23}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.F_TEST.functionParameter.number2.name',
- detail: 'formula.functionList.F_TEST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.F_TEST.functionParameter.array2.name',
+ detail: 'formula.functionList.F_TEST.functionParameter.array2.detail',
+ example: '{45.35,47.65;17.56,18.44;16.09,16.91}',
require: 1,
repeat: 0,
},
@@ -767,16 +914,9 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.FISHER.abstract',
functionParameter: [
{
- name: 'formula.functionList.FISHER.functionParameter.number1.name',
- detail: 'formula.functionList.FISHER.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.FISHER.functionParameter.number2.name',
- detail: 'formula.functionList.FISHER.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FISHER.functionParameter.x.name',
+ detail: 'formula.functionList.FISHER.functionParameter.x.detail',
+ example: '0.75',
require: 1,
repeat: 0,
},
@@ -789,16 +929,9 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.FISHERINV.abstract',
functionParameter: [
{
- name: 'formula.functionList.FISHERINV.functionParameter.number1.name',
- detail: 'formula.functionList.FISHERINV.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.FISHERINV.functionParameter.number2.name',
- detail: 'formula.functionList.FISHERINV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FISHERINV.functionParameter.y.name',
+ detail: 'formula.functionList.FISHERINV.functionParameter.y.detail',
+ example: '0.75',
require: 1,
repeat: 0,
},
@@ -811,16 +944,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.FORECAST.abstract',
functionParameter: [
{
- name: 'formula.functionList.FORECAST.functionParameter.number1.name',
- detail: 'formula.functionList.FORECAST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FORECAST.functionParameter.x.name',
+ detail: 'formula.functionList.FORECAST.functionParameter.x.detail',
+ example: '30',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.FORECAST.functionParameter.number2.name',
- detail: 'formula.functionList.FORECAST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FORECAST.functionParameter.knownYs.name',
+ detail: 'formula.functionList.FORECAST.functionParameter.knownYs.detail',
+ example: '{6,7,9,15,21}',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.FORECAST.functionParameter.knownXs.name',
+ detail: 'formula.functionList.FORECAST.functionParameter.knownXs.detail',
+ example: '{20,28,31,38,40}',
require: 1,
repeat: 0,
},
@@ -921,16 +1061,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.FORECAST_LINEAR.abstract',
functionParameter: [
{
- name: 'formula.functionList.FORECAST_LINEAR.functionParameter.number1.name',
- detail: 'formula.functionList.FORECAST_LINEAR.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FORECAST_LINEAR.functionParameter.x.name',
+ detail: 'formula.functionList.FORECAST_LINEAR.functionParameter.x.detail',
+ example: '30',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.FORECAST_LINEAR.functionParameter.number2.name',
- detail: 'formula.functionList.FORECAST_LINEAR.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FORECAST_LINEAR.functionParameter.knownYs.name',
+ detail: 'formula.functionList.FORECAST_LINEAR.functionParameter.knownYs.detail',
+ example: '{6,7,9,15,21}',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.FORECAST_LINEAR.functionParameter.knownXs.name',
+ detail: 'formula.functionList.FORECAST_LINEAR.functionParameter.knownXs.detail',
+ example: '{20,28,31,38,40}',
require: 1,
repeat: 0,
},
@@ -1185,16 +1332,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.INTERCEPT.abstract',
functionParameter: [
{
- name: 'formula.functionList.INTERCEPT.functionParameter.number1.name',
- detail: 'formula.functionList.INTERCEPT.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.INTERCEPT.functionParameter.knownYs.name',
+ detail: 'formula.functionList.INTERCEPT.functionParameter.knownYs.detail',
+ example: '{6,7,9,15,21}',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.INTERCEPT.functionParameter.number2.name',
- detail: 'formula.functionList.INTERCEPT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.INTERCEPT.functionParameter.knownXs.name',
+ detail: 'formula.functionList.INTERCEPT.functionParameter.knownXs.detail',
+ example: '{20,28,31,38,40}',
require: 1,
repeat: 0,
},
@@ -1603,16 +1750,30 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.NORM_DIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORM_DIST.functionParameter.number1.name',
- detail: 'formula.functionList.NORM_DIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORM_DIST.functionParameter.x.name',
+ detail: 'formula.functionList.NORM_DIST.functionParameter.x.detail',
+ example: '42',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.NORM_DIST.functionParameter.number2.name',
- detail: 'formula.functionList.NORM_DIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORM_DIST.functionParameter.mean.name',
+ detail: 'formula.functionList.NORM_DIST.functionParameter.mean.detail',
+ example: '40',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.NORM_DIST.functionParameter.standardDev.name',
+ detail: 'formula.functionList.NORM_DIST.functionParameter.standardDev.detail',
+ example: '1.5',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.NORM_DIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.NORM_DIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
@@ -1625,16 +1786,23 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.NORM_INV.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORM_INV.functionParameter.number1.name',
- detail: 'formula.functionList.NORM_INV.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORM_INV.functionParameter.probability.name',
+ detail: 'formula.functionList.NORM_INV.functionParameter.probability.detail',
+ example: '0.908789',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.NORM_INV.functionParameter.number2.name',
- detail: 'formula.functionList.NORM_INV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORM_INV.functionParameter.mean.name',
+ detail: 'formula.functionList.NORM_INV.functionParameter.mean.detail',
+ example: '40',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.NORM_INV.functionParameter.standardDev.name',
+ detail: 'formula.functionList.NORM_INV.functionParameter.standardDev.detail',
+ example: '1.5',
require: 1,
repeat: 0,
},
@@ -1647,16 +1815,16 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.NORM_S_DIST.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORM_S_DIST.functionParameter.number1.name',
- detail: 'formula.functionList.NORM_S_DIST.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORM_S_DIST.functionParameter.z.name',
+ detail: 'formula.functionList.NORM_S_DIST.functionParameter.z.detail',
+ example: '1.333333',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.NORM_S_DIST.functionParameter.number2.name',
- detail: 'formula.functionList.NORM_S_DIST.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORM_S_DIST.functionParameter.cumulative.name',
+ detail: 'formula.functionList.NORM_S_DIST.functionParameter.cumulative.detail',
+ example: 'true',
require: 1,
repeat: 0,
},
@@ -1669,16 +1837,9 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [
abstract: 'formula.functionList.NORM_S_INV.abstract',
functionParameter: [
{
- name: 'formula.functionList.NORM_S_INV.functionParameter.number1.name',
- detail: 'formula.functionList.NORM_S_INV.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.NORM_S_INV.functionParameter.number2.name',
- detail: 'formula.functionList.NORM_S_INV.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.NORM_S_INV.functionParameter.probability.name',
+ detail: 'formula.functionList.NORM_S_INV.functionParameter.probability.detail',
+ example: '0.908789',
require: 1,
repeat: 0,
},