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
babe7487
Commit
babe7487
authored
Jul 13, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change NEGBINOMDIST function(+ add test)
parent
53b963ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
42 deletions
+28
-42
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+11
-0
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+17
-42
No files found.
cell/.unit-tests/FormulaTests.js
View file @
babe7487
...
...
@@ -4080,6 +4080,17 @@ $( function () {
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
7
)
-
0
,
0.0550487
);
}
);
test
(
"
Test:
\"
NEGBINOMDIST
\"
"
,
function
()
{
ws
.
getRange2
(
"
F202
"
).
setValue
(
"
10
"
);
ws
.
getRange2
(
"
F203
"
).
setValue
(
"
5
"
);
ws
.
getRange2
(
"
F204
"
).
setValue
(
"
0.25
"
);
oParser
=
new
parserFormula
(
"
NEGBINOMDIST(F202,F203,F204)
"
,
"
F1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
8
)
-
0
,
0.05504866
);
}
);
test
(
"
Test:
\"
NORMSINV
\"
"
,
function
()
{
function
normsinv
(
x
)
{
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
babe7487
...
...
@@ -5307,9 +5307,7 @@
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cNEGBINOMDIST
()
{
this
.
name
=
"
NEGBINOMDIST
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
cBaseFunction
.
call
(
this
,
"
NEGBINOMDIST
"
);
}
cNEGBINOMDIST
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
...
...
@@ -5317,12 +5315,22 @@
cNEGBINOMDIST
.
prototype
.
argumentsMin
=
3
;
cNEGBINOMDIST
.
prototype
.
argumentsMax
=
3
;
cNEGBINOMDIST
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
];
var
oArguments
=
this
.
_prepareArguments
(
arg
,
arguments
[
1
],
true
);
var
argClone
=
oArguments
.
args
;
argClone
[
0
]
=
argClone
[
0
].
tocNumber
();
argClone
[
1
]
=
argClone
[
1
].
tocNumber
();
argClone
[
2
]
=
argClone
[
2
].
tocNumber
();
var
argError
;
if
(
argError
=
this
.
_checkErrorArg
(
argClone
))
{
return
this
.
value
=
argError
;
}
function
negbinomdist
(
x
,
r
,
p
)
{
x
=
parseInt
(
x
.
getValue
())
;
r
=
parseInt
(
r
.
getValue
())
;
p
=
p
.
getValue
()
;
function
negbinomdist
(
argArray
)
{
var
x
=
argArray
[
0
]
;
var
r
=
argArray
[
1
]
;
var
p
=
argArray
[
2
]
;
if
(
x
<
0
||
r
<
1
||
p
<
0
||
p
>
1
)
{
return
new
cError
(
cErrorType
.
not_numeric
);
}
else
{
...
...
@@ -5330,40 +5338,7 @@
}
}
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArea3D
)
{
arg0
=
arg0
.
cross
(
arguments
[
1
]);
}
else
if
(
arg0
instanceof
cArray
)
{
arg0
=
arg0
.
getElement
(
0
);
}
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
]);
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
=
arg1
.
getElement
(
0
);
}
if
(
arg2
instanceof
cArea
||
arg2
instanceof
cArea3D
)
{
arg2
=
arg2
.
cross
(
arguments
[
1
]);
}
else
if
(
arg2
instanceof
cArray
)
{
arg2
=
arg2
.
getElement
(
0
);
}
arg0
=
arg0
.
tocNumber
();
arg1
=
arg1
.
tocNumber
();
arg2
=
arg2
.
tocNumber
();
if
(
arg0
instanceof
cError
)
{
return
this
.
value
=
arg0
;
}
if
(
arg1
instanceof
cError
)
{
return
this
.
value
=
arg1
;
}
if
(
arg2
instanceof
cError
)
{
return
this
.
value
=
arg2
;
}
return
this
.
value
=
negbinomdist
(
arg0
,
arg1
,
arg2
);
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
negbinomdist
);
};
/**
...
...
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