commit
message
Linking formulas that are incorrectly named.
author
Ben Vogt <[email protected]>
date
2017-01-10 23:30:02
stats
3 file(s) changed,
17 insertions(+),
9 deletions(-)
files
README.md
src/SupportedFormulas.ts
tests/SheetFormulaTest.ts
1diff --git a/README.md b/README.md
2index ef11b73..5f2a486 100644
3--- a/README.md
4+++ b/README.md
5@@ -9,8 +9,8 @@ Things I should do.
6 * Include fail state values for all formulas
7
8 ### Write formulas for missing ones
9-* FDIST vs F.DIST, differentiate.
10-* FINV vs F.INV, differentiate.
11+* FDIST
12+* FINV
13 * SUM_ formulas
14 * ACCRINT
15
16diff --git a/src/SupportedFormulas.ts b/src/SupportedFormulas.ts
17index 605f5ec..770e1f4 100644
18--- a/src/SupportedFormulas.ts
19+++ b/src/SupportedFormulas.ts
20@@ -1,5 +1,6 @@
21 /// <reference path="../node_modules/moment/moment.d.ts"/>
22 import * as moment from "moment";
23+import * as Formula from "formulajs"
24
25 const SUPPORTED_FORMULAS = [
26 'ABS', 'ACCRINT', 'ACOS', 'ACOSH', 'ACOTH', 'AND', 'ARABIC', 'ASIN', 'ASINH', 'ATAN', 'ATAN2', 'ATANH', 'AVEDEV', 'AVERAGE', 'AVERAGEA', 'AVERAGEIF',
27@@ -21,6 +22,8 @@ const SUPPORTED_FORMULAS = [
28 ];
29
30 const OverrideFormulas = {
31+ "F.DIST": Formula["FDIST"],
32+ "F.INV": Formula["FINV"],
33 ATAN2: function (x, y) {
34 return Math.atan2(y, x);
35 },
36diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
37index 09ebb49..fe7981e 100644
38--- a/tests/SheetFormulaTest.ts
39+++ b/tests/SheetFormulaTest.ts
40@@ -317,27 +317,31 @@ testFormula('=EXPONDIST(4, 0.5, false)', 0.06766764161830635);
41 // Test FALSE
42 testFormula('=FALSE()', false);
43
44+// Test F.DIST
45+
46+testFormula('=F.DIST(15.35, 7, 6, false)', 0.0003451054686025578);
47+testFormula('=F.DIST(15.35, 7, 6, true)', 0.9980694465675269);
48+
49 // Test FDIST
50-// TODO: In GS, this is really called F.DIST
51+// TODO: This should work.
52 /*
53 * F.DIST Calculates the left-tailed F probability distribution (degree of diversity) for two data sets with given input x. Alternately called Fisher-Snedecor distribution or Snedecor's F distribution.
54 * FDIST Calculates the right-tailed F probability distribution (degree of diversity) for two data sets with given input x. Alternately called Fisher-Snedecor distribution or Snedecor's F distribution.
55 *
56 * F.DIST is left-tailed. FDIST is right-tailed.
57 */
58-testFormula('=FDIST(15.35, 7, 6, false)', 0.0003451054686025578);
59-testFormula('=FDIST(15.35, 7, 6, true)', 0.9980694465675269);
60
61+// Test F.INV
62+testFormula('=F.INV(0.42, 2, 3)', 0.6567804059458624);
63
64 // Test FINV
65-// TODO: In GS, this is really called F.INV
66+// TODO: This should work.
67 /*
68 * FINV Calculates the inverse of the right-tailed F probability distribution. Also called the Fisher-Snedecor distribution or Snedecor’s F distribution.
69 * F.INV Calculates the inverse of the left-tailed F probability distribution. Also called the Fisher-Snedecor distribution or Snedecor’s F distribution.
70 *
71 * F.INV is left-tailed. FINV is right-tailed.
72 */
73-testFormula('=FINV(0.42, 2, 3)', 0.6567804059458624);
74
75 // Test FISHER
76 testFormula('=FISHER(0.962)', 1.972066740199461);