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
947efa98
Commit
947efa98
authored
Jun 22, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add PERCENTRANK.INC/PERCENTRANK.EXC formulas
parent
b4da50f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
105 deletions
+141
-105
cell/model/FormulaObjects/_xlfnFunctions.js
cell/model/FormulaObjects/_xlfnFunctions.js
+2
-26
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+139
-79
No files found.
cell/model/FormulaObjects/_xlfnFunctions.js
View file @
947efa98
...
...
@@ -62,7 +62,7 @@
cFORECAST_ETS_CONFINT
,
cFORECAST_ETS_SEASONALITY
,
cFORECAST_ETS_STAT
,
cFORECAST_LINEAR
,
cHYPGEOM_DIST
,
cMODE_MULT
,
cMODE_SNGL
,
cNEGBINOM_DIST
,
cNORM_DIST
,
cNORM_INV
,
cNORM_S_DIST
,
cNORM_S_INV
,
cPER
CENTRANK_EXC
,
cPERCENTRANK_INC
,
cPER
MUTATIONA
,
cPHI
,
cPOISSON_DIST
,
cQUARTILE_EXC
,
cQUARTILE_INC
,
cPERMUTATIONA
,
cPHI
,
cPOISSON_DIST
,
cQUARTILE_EXC
,
cQUARTILE_INC
,
cSKEW_P
,
cSTDEV_P
,
cSTDEV_S
,
cT_TEST
,
cVAR_P
,
cVAR_S
,
cWEIBULL_DIST
,
cZ_TEST
);
cFormulaFunctionGroup
[
'
Financial
'
]
=
cFormulaFunctionGroup
[
'
Financial
'
]
||
[];
...
...
@@ -80,7 +80,7 @@
cCONFIDENCE_NORM
,
cCONFIDENCE_T
,
cCOVARIANCE_P
,
cCOVARIANCE_S
,
cF_TEST
,
cFORECAST_ETS
,
cFORECAST_ETS_CONFINT
,
cFORECAST_ETS_SEASONALITY
,
cFORECAST_ETS_STAT
,
cFORECAST_LINEAR
,
cHYPGEOM_DIST
,
cMODE_MULT
,
cMODE_SNGL
,
cNEGBINOM_DIST
,
cNORM_DIST
,
cNORM_INV
,
cNORM_S_DIST
,
cNORM_S_INV
,
cPER
CENTRANK_EXC
,
cPERCENTRANK_INC
,
cPER
MUTATIONA
,
cPHI
,
cPOISSON_DIST
,
cQUARTILE_EXC
,
cQUARTILE_INC
,
cPERMUTATIONA
,
cPHI
,
cPOISSON_DIST
,
cQUARTILE_EXC
,
cQUARTILE_INC
,
cSKEW_P
,
cSTDEV_P
,
cSTDEV_S
,
cT_TEST
,
cVAR_P
,
cVAR_S
,
cWEIBULL_DIST
,
cZ_TEST
,
cPDURATION
,
cRRI
,
cAGGREGATE
,
cMUNIT
,
cFORMULATEXT
,
cISFORMULA
,
cSHEET
,
cSHEETS
);
...
...
@@ -552,30 +552,6 @@
cPDURATION
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cPDURATION
.
prototype
.
constructor
=
cPDURATION
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cPERCENTRANK_EXC
()
{
cBaseFunction
.
call
(
this
,
"
PERCENTRANK.EXC
"
);
this
.
isXLFN
=
true
;
}
cPERCENTRANK_EXC
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cPERCENTRANK_EXC
.
prototype
.
constructor
=
cPERCENTRANK_EXC
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cPERCENTRANK_INC
()
{
cBaseFunction
.
call
(
this
,
"
PERCENTRANK.INC
"
);
this
.
isXLFN
=
true
;
}
cPERCENTRANK_INC
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cPERCENTRANK_INC
.
prototype
.
constructor
=
cPERCENTRANK_INC
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
947efa98
...
...
@@ -67,10 +67,10 @@
cFREQUENCY
,
cFTEST
,
cGAMMA
,
cGAMMA_DIST
,
cGAMMADIST
,
cGAMMA_INV
,
cGAMMAINV
,
cGAMMALN
,
cGAMMALN_PRECISE
,
cGAUSS
,
cGEOMEAN
,
cGROWTH
,
cHARMEAN
,
cHYPGEOMDIST
,
cINTERCEPT
,
cKURT
,
cLARGE
,
cLINEST
,
cLOGEST
,
cLOGINV
,
cLOGNORM_DIST
,
cLOGNORM_INV
,
cLOGNORMDIST
,
cMAX
,
cMAXA
,
cMEDIAN
,
cMIN
,
cMINA
,
cMODE
,
cNEGBINOMDIST
,
cNORMDIST
,
cNORMINV
,
cNORMSDIST
,
cNORMSINV
,
cPEARSON
,
cPERCENTILE
,
cPERCENTILE_EXC
,
cPERCENTILE_INC
,
cPERCENTRANK
,
cPER
MUT
,
cPOISSON
,
cPROB
,
cQUARTILE
,
cRANK
,
c
RANK_AVG
,
cRANK_EQ
,
cRSQ
,
cSKEW
,
cSLOPE
,
cSMALL
,
cSTANDARDIZE
,
cSTDEV
,
cSTDEVA
,
cSTDEVP
,
cSTDEVPA
,
cSTEYX
,
cTDIST
,
c
T_DIST
,
cT_DIST_2T
,
cT_DIST_RT
,
cT_INV
,
cT_INV_2T
,
cTINV
,
cTREND
,
cTRIMMEAN
,
cTTEST
,
cVAR
,
cVARA
,
cVARP
,
cVARPA
,
cWEIBULL
,
cZTEST
);
cNORMSDIST
,
cNORMSINV
,
cPEARSON
,
cPERCENTILE
,
cPERCENTILE_EXC
,
cPERCENTILE_INC
,
cPERCENTRANK
,
cPER
CENTRANK_EXC
,
c
PERCENTRANK_INC
,
cPERMUT
,
cPOISSON
,
cPROB
,
cQUARTILE
,
cRANK
,
cRANK_AVG
,
cRANK_EQ
,
cRSQ
,
cSKEW
,
cSLOPE
,
cSMALL
,
c
STANDARDIZE
,
cSTDEV
,
cSTDEVA
,
cSTDEVP
,
cSTDEVPA
,
cSTEYX
,
cTDIST
,
cT_DIST
,
cT_DIST_2T
,
cT_DIST_RT
,
cT_INV
,
c
T_INV_2T
,
cTINV
,
cTREND
,
cTRIMMEAN
,
cTTEST
,
cVAR
,
cVARA
,
cVARP
,
c
VARPA
,
cWEIBULL
,
cZTEST
);
cFormulaFunctionGroup
[
'
NotRealised
'
]
=
cFormulaFunctionGroup
[
'
NotRealised
'
]
||
[];
cFormulaFunctionGroup
[
'
NotRealised
'
].
push
(
cCHITEST
,
cFTEST
,
cGROWTH
,
cLINEST
,
cLOGEST
,
cTREND
,
...
...
@@ -353,6 +353,65 @@
}
}
function
percentrank
(
tA
,
fNum
,
k
,
bInclusive
)
{
tA
.
sort
(
fSortAscending
);
var
nSize
=
tA
.
length
;
if
(
k
<
1
){
return
new
cError
(
cErrorType
.
not_numeric
);
}
else
if
(
tA
.
length
<
1
||
nSize
===
0
)
{
return
new
cError
(
cErrorType
.
not_available
);
}
else
{
if
(
fNum
<
tA
[
0
]
||
fNum
>
tA
[
nSize
-
1
])
{
return
new
cError
(
cErrorType
.
not_available
);
}
else
if
(
nSize
===
1
)
{
return
new
cNumber
(
1
);
}
else
{
if
(
fNum
===
tA
[
0
]
){
if
(
bInclusive
){
fRes
=
0
;
}
else
{
fRes
=
1
/
(
nSize
+
1
);
}
}
else
{
var
fRes
,
nOldCount
=
0
,
fOldVal
=
tA
[
0
],
i
;
for
(
i
=
1
;
i
<
nSize
&&
tA
[
i
]
<
fNum
;
i
++
)
{
if
(
tA
[
i
]
!==
fOldVal
)
{
nOldCount
=
i
;
fOldVal
=
tA
[
i
];
}
}
if
(
tA
[
i
]
!==
fOldVal
)
{
nOldCount
=
i
;
}
if
(
fNum
===
tA
[
i
])
{
if
(
bInclusive
){
fRes
=
nOldCount
/
(
nSize
-
1
);
}
else
{
fRes
=
(
i
+
1
)
/
(
nSize
+
1
);
}
}
else
{
if
(
nOldCount
===
0
)
{
fRes
=
0
;
}
else
{
var
fFract
=
(
fNum
-
tA
[
nOldCount
-
1
]
)
/
(
tA
[
nOldCount
]
-
tA
[
nOldCount
-
1
]
);
if
(
bInclusive
){
fRes
=
fRes
=
(
nOldCount
-
1
+
fFract
)
/
(
nSize
-
1
);
}
else
{
fRes
=
(
nOldCount
+
fFract
)
/
(
nSize
+
1
);
}
}
}
}
return
new
cNumber
(
fRes
.
toString
().
substr
(
0
,
fRes
.
toString
().
indexOf
(
"
.
"
)
+
1
+
k
)
-
0
);
}
}
}
function
getGamma
(
fZ
)
{
var
fLogPi
=
Math
.
log
(
Math
.
PI
);
var
fLogDblMax
=
Math
.
log
(
2.22507
e
+
308
);
...
...
@@ -5149,101 +5208,102 @@
cPERCENTRANK
.
prototype
.
argumentsMax
=
3
;
cPERCENTRANK
.
prototype
.
Calculate
=
function
(
arg
)
{
function
percentrank
(
A
,
x
,
k
)
{
var
tA
=
[],
t
,
i
;
var
oArguments
=
this
.
_prepareArguments
(
arg
,
arguments
[
1
],
true
,
[
cElementType
.
array
]);
var
argClone
=
oArguments
.
args
;
k
=
k
.
getValue
();
argClone
[
1
]
=
argClone
[
1
].
tocNumber
();
argClone
[
2
]
=
argClone
[
2
]
?
argClone
[
2
]
:
new
cNumber
(
3
);
for
(
i
=
0
;
i
<
A
.
length
;
i
++
)
{
t
=
A
[
i
].
tocNumber
();
if
(
t
instanceof
cNumber
)
{
tA
.
push
(
t
.
getValue
())
}
}
var
argError
;
if
(
argError
=
this
.
_checkErrorArg
(
argClone
))
{
return
this
.
value
=
argError
;
}
var
fNum
=
x
.
getValue
();
function
calcPercenTrank
(
argArray
)
{
tA
.
sort
(
fSortAscending
)
;
var
tA
=
[],
A
=
argArray
[
0
],
fNum
=
argArray
[
1
],
k
=
argArray
[
2
]
;
var
nSize
=
tA
.
length
;
if
(
tA
.
length
<
1
||
nSize
==
0
)
{
return
new
cError
(
cErrorType
.
not_available
);
}
else
{
if
(
fNum
<
tA
[
0
]
||
fNum
>
tA
[
nSize
-
1
])
{
return
new
cError
(
cErrorType
.
not_available
);
}
else
if
(
nSize
==
1
)
{
return
new
cNumber
(
1
);
}
else
{
var
fRes
,
nOldCount
=
0
,
fOldVal
=
tA
[
0
];
for
(
i
=
1
;
i
<
nSize
&&
tA
[
i
]
<
fNum
;
i
++
)
{
if
(
tA
[
i
]
!=
fOldVal
)
{
nOldCount
=
i
;
fOldVal
=
tA
[
i
];
}
}
if
(
tA
[
i
]
!=
fOldVal
)
{
nOldCount
=
i
;
}
if
(
fNum
==
tA
[
i
])
{
fRes
=
nOldCount
/
(
nSize
-
1
);
}
else
{
if
(
nOldCount
==
0
)
{
fRes
=
0.0
;
}
else
{
var
fFract
=
(
fNum
-
tA
[
nOldCount
-
1
]
)
/
(
tA
[
nOldCount
]
-
tA
[
nOldCount
-
1
]
);
fRes
=
(
nOldCount
-
1
+
fFract
)
/
(
nSize
-
1
);
}
for
(
var
i
=
0
;
i
<
A
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
A
[
i
].
length
;
j
++
)
{
if
(
A
[
i
][
j
]
instanceof
cError
)
{
return
A
[
i
][
j
];
}
else
if
(
A
[
i
][
j
]
instanceof
cNumber
)
{
tA
.
push
(
A
[
i
][
j
].
getValue
());
}
else
if
(
A
[
i
][
j
]
instanceof
cBool
)
{
tA
.
push
(
A
[
i
][
j
].
tocNumber
().
getValue
());
}
return
new
cNumber
(
fRes
.
toString
().
substr
(
0
,
fRes
.
toString
().
indexOf
(
"
.
"
)
+
1
+
k
)
-
0
);
}
}
return
percentrank
(
tA
,
fNum
,
k
,
true
);
}
var
arr0
=
[],
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
]
?
arg
[
2
]
:
new
cNumber
(
3
);
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calcPercenTrank
);
};
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArea3D
)
{
arg0
.
foreach2
(
function
(
elem
)
{
if
(
elem
instanceof
cNumber
)
{
arr0
.
push
(
elem
);
}
});
}
else
if
(
arg0
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
)
{
if
(
elem
instanceof
cNumber
)
{
arr0
.
push
(
elem
);
}
});
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cPERCENTRANK_EXC
()
{
this
.
name
=
"
PERCENTRANK.EXC
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
]);
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
=
arg1
.
getElement
(
0
);
}
cPERCENTRANK_EXC
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cPERCENTRANK_EXC
.
prototype
.
constructor
=
cPERCENTRANK_EXC
;
cPERCENTRANK_EXC
.
prototype
.
argumentsMin
=
2
;
cPERCENTRANK_EXC
.
prototype
.
argumentsMax
=
3
;
cPERCENTRANK_EXC
.
prototype
.
isXLFN
=
true
;
cPERCENTRANK_EXC
.
prototype
.
Calculate
=
function
(
arg
)
{
if
(
arg2
instanceof
cArea
||
arg2
instanceof
cArea3D
)
{
arg2
=
arg2
.
cross
(
arguments
[
1
]);
}
else
if
(
arg2
instanceof
cArray
)
{
arg2
=
arg2
.
getElement
(
0
);
}
var
oArguments
=
this
.
_prepareArguments
(
arg
,
arguments
[
1
],
true
,
[
cElementType
.
array
]);
var
argClone
=
oArguments
.
args
;
arg
1
=
arg1
.
tocNumber
();
arg
2
=
arg2
.
tocNumber
(
);
arg
Clone
[
1
]
=
argClone
[
1
]
.
tocNumber
();
arg
Clone
[
2
]
=
argClone
[
2
]
?
argClone
[
2
]
:
new
cNumber
(
3
);
if
(
arg1
instanceof
cError
)
{
return
this
.
value
=
arg1
;
}
if
(
arg2
instanceof
cError
)
{
return
this
.
value
=
arg2
;
var
argError
;
if
(
argError
=
this
.
_checkErrorArg
(
argClone
))
{
return
this
.
value
=
argError
;
}
return
this
.
value
=
percentrank
(
arr0
,
arg1
,
arg2
);
function
calcPercenTrank
(
argArray
)
{
var
tA
=
[],
A
=
argArray
[
0
],
fNum
=
argArray
[
1
],
k
=
argArray
[
2
];
for
(
var
i
=
0
;
i
<
A
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
A
[
i
].
length
;
j
++
)
{
if
(
A
[
i
][
j
]
instanceof
cError
)
{
return
A
[
i
][
j
];
}
else
if
(
A
[
i
][
j
]
instanceof
cNumber
)
{
tA
.
push
(
A
[
i
][
j
].
getValue
());
}
else
if
(
A
[
i
][
j
]
instanceof
cBool
)
{
tA
.
push
(
A
[
i
][
j
].
tocNumber
().
getValue
());
}
}
}
return
percentrank
(
tA
,
fNum
,
k
);
}
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calcPercenTrank
);
};
/**
* @constructor
* @extends {cPERCENTRANK}
*/
function
cPERCENTRANK_INC
()
{
cPERCENTRANK
.
call
(
this
);
this
.
name
=
"
PERCENTRANK.INC
"
;
}
cPERCENTRANK_INC
.
prototype
=
Object
.
create
(
cPERCENTRANK
.
prototype
);
cPERCENTRANK_INC
.
prototype
.
constructor
=
cPERCENTRANK_INC
;
cPERCENTRANK_INC
.
prototype
.
isXLFN
=
true
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
...
...
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