Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
aed39e23
Commit
aed39e23
authored
Jun 14, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add CHIINV formula
parent
02ccc50f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+9
-0
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+53
-0
No files found.
cell/.unit-tests/FormulaTests.js
View file @
aed39e23
...
...
@@ -1065,6 +1065,15 @@ $( function () {
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
7
)
-
0
,
0.0500006
,
"
CHIDIST(A2,A3)
"
);
}
);
test
(
"
Test:
\"
CHIINV
\"
"
,
function
()
{
ws
.
getRange2
(
"
A2
"
).
setValue
(
"
0.050001
"
);
ws
.
getRange2
(
"
A3
"
).
setValue
(
"
10
"
);
oParser
=
new
parserFormula
(
"
CHIINV(A2,A3)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
"
CHIINV(A2,A3)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
6
)
-
0
,
18.306973
,
"
CHIINV(A2,A3)
"
);
}
);
test
(
"
Test:
\"
BETA.INV
\"
"
,
function
()
{
ws
.
getRange2
(
"
A2
"
).
setValue
(
"
0.685470581
"
);
ws
.
getRange2
(
"
A3
"
).
setValue
(
"
8
"
);
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
aed39e23
...
...
@@ -885,6 +885,18 @@
return
res
;
};
function
CHIDISTFUNCTION
(
fp
,
fDF
){
this
.
fp
=
fp
;
this
.
fDF
=
fDF
;
}
CHIDISTFUNCTION
.
prototype
.
GetValue
=
function
(
x
){
var
res
;
var
betaDistVal
=
getChiDist
(
x
,
this
.
fDF
);
res
=
this
.
fp
-
betaDistVal
;
return
res
;
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
...
...
@@ -1588,6 +1600,47 @@
cCHIINV
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCHIINV
.
prototype
.
constructor
=
cCHIINV
;
cCHIINV
.
prototype
.
argumentsMin
=
2
;
cCHIINV
.
prototype
.
argumentsMax
=
2
;
cCHIINV
.
prototype
.
Calculate
=
function
(
arg
)
{
var
oArguments
=
this
.
_prepareArguments
(
arg
,
arguments
[
1
],
true
);
var
argClone
=
oArguments
.
args
;
argClone
[
0
]
=
argClone
[
0
].
tocNumber
();
argClone
[
1
]
=
argClone
[
1
].
tocNumber
();
var
argError
;
if
(
argError
=
this
.
_checkErrorArg
(
argClone
))
{
return
this
.
value
=
argError
;
}
var
calcTDist
=
function
(
argArray
){
var
fP
=
argArray
[
0
];
var
fDF
=
parseInt
(
argArray
[
1
]);
if
(
fDF
<
1
||
fP
<=
0
||
fP
>
1
){
return
new
cError
(
cErrorType
.
not_numeric
);
}
var
aFunc
=
new
CHIDISTFUNCTION
(
fP
,
fDF
);
var
oVal
=
iterateInverse
(
aFunc
,
fDF
*
0.5
,
fDF
);
var
bConvError
=
oVal
.
bError
;
if
(
bConvError
){
return
new
cError
(
cErrorType
.
not_numeric
);
}
var
res
=
oVal
.
val
;
return
null
!==
res
&&
!
isNaN
(
res
)
?
new
cNumber
(
res
)
:
new
cError
(
cErrorType
.
wrong_value_type
);
};
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calcTDist
);
};
cCHIINV
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
(probability, deg_freedom)
"
};
};
/**
* @constructor
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment