Commit f467f828 authored by GoshaZotov's avatar GoshaZotov

add cPERCENTILE_EXC/cPERCENTILE_INC formulas

parent 5761a27a
......@@ -61,7 +61,7 @@
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, cPERCENTILE_EXC, cPERCENTILE_INC,
cNEGBINOM_DIST, cNORM_DIST, cNORM_INV, cNORM_S_DIST, cNORM_S_INV,
cPERCENTRANK_EXC, cPERCENTRANK_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);
......@@ -79,7 +79,7 @@
cERF_PRECISE, cERFC_PRECISE, cDBCS, cUNICHAR, cUNICODE, cBINOM_DIST, cBINOM_DIST_RANGE, cBINOM_INV, cCHISQ_TEST,
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, cPERCENTILE_EXC, cPERCENTILE_INC,
cNEGBINOM_DIST, cNORM_DIST, cNORM_INV, cNORM_S_DIST, cNORM_S_INV,
cPERCENTRANK_EXC, cPERCENTRANK_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 cPERCENTILE_EXC() {
cBaseFunction.call(this, "PERCENTILE.EXC");
this.isXLFN = true;
}
cPERCENTILE_EXC.prototype = Object.create(cBaseFunction.prototype);
cPERCENTILE_EXC.prototype.constructor = cPERCENTILE_EXC;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cPERCENTILE_INC() {
cBaseFunction.call(this, "PERCENTILE.INC");
this.isXLFN = true;
}
cPERCENTILE_INC.prototype = Object.create(cBaseFunction.prototype);
cPERCENTILE_INC.prototype.constructor = cPERCENTILE_INC;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -67,7 +67,7 @@
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, cPERCENTRANK, cPERMUT, cPOISSON, cPROB, cQUARTILE, cRANK,
cNORMSDIST, cNORMSINV, cPEARSON, cPERCENTILE, cPERCENTILE_EXC, cPERCENTILE_INC, cPERCENTRANK, cPERMUT, cPOISSON, cPROB, cQUARTILE, cRANK,
cRANK_AVG, cRANK_EQ, cRSQ, cSKEW, cSLOPE, cSMALL, cSTANDARDIZE, cSTDEV, cSTDEVA, cSTDEVP, cSTDEVPA, cSTEYX, cTDIST,
cT_DIST, cT_DIST_2T, cT_DIST_RT, cT_INV, cT_INV_2T, cTINV, cTREND, cTRIMMEAN, cTTEST, cVAR, cVARA, cVARP,
cVARPA, cWEIBULL, cZTEST);
......@@ -333,6 +333,26 @@
}
}
function getPercentileExclusive(values, alpha) {
values.sort(fSortAscending);
var nSize1 = values.length + 1;
if ( nSize1 == 1){
return new cError(cErrorType.wrong_value_type);
}
if ( alpha * nSize1 < 1 || alpha * nSize1 > nSize1 - 1 ){
return new cError(cErrorType.not_numeric);
}
var nIndex = Math.floor(alpha * nSize1 - 1);
var fDiff = alpha * nSize1 - 1 - Math.floor(alpha * nSize1 - 1);
if (fDiff === 0.0) {
return new cNumber(values[nIndex]);
} else {
return new cNumber(values[nIndex] + fDiff * (values[nIndex + 1] - values[nIndex]));
}
}
function getGamma(fZ) {
var fLogPi = Math.log(Math.PI);
var fLogDblMax = Math.log(2.22507e+308);
......@@ -5051,6 +5071,68 @@
return this.value = this._findArrayInNumberArguments(oArguments, percentile);
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cPERCENTILE_EXC() {
this.name = "PERCENTILE.EXC";
this.value = null;
this.argumentsCurrent = 0;
}
cPERCENTILE_EXC.prototype = Object.create(cBaseFunction.prototype);
cPERCENTILE_EXC.prototype.constructor = cPERCENTILE_EXC;
cPERCENTILE_EXC.prototype.argumentsMin = 2;
cPERCENTILE_EXC.prototype.argumentsMax = 2;
cPERCENTILE_EXC.prototype.isXLFN = true;
cPERCENTILE_EXC.prototype.numFormat = AscCommonExcel.cNumFormatNone;
cPERCENTILE_EXC.prototype.Calculate = function (arg) {
function percentile(argArray) {
var tA = [], A = argArray[0], alpha = argArray[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 getPercentileExclusive(tA, alpha);
}
var oArguments = this._prepareArguments(arg, arguments[1], true, [cElementType.array]);
var argClone = oArguments.args;
argClone[1] = argClone[1].tocNumber();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
return this.value = this._findArrayInNumberArguments(oArguments, percentile);
};
/**
* @constructor
* @extends {cPERCENTILE}
*/
function cPERCENTILE_INC() {
cPERCENTILE.call(this);
this.name = "PERCENTILE.INC";
}
cPERCENTILE_INC.prototype = Object.create(cPERCENTILE.prototype);
cPERCENTILE_INC.prototype.constructor = cPERCENTILE_INC;
cPERCENTILE_INC.prototype.isXLFN = true;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment