Commit d8f526d7 authored by GoshaZotov's avatar GoshaZotov

add NORM.S.DIST formula

parent b43c990b
......@@ -4028,7 +4028,19 @@ $( function () {
} );
test( "Test: \"NEGBINOMDIST\"", function () {
test( "Test: \"NORM.S.DIST\"", function () {
oParser = new parserFormula( "NORM.S.DIST(1.333333,TRUE)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue().toFixed(9) - 0, 0.908788726 );
oParser = new parserFormula( "NORM.S.DIST(1.333333,FALSE)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue().toFixed(9) - 0, 0.164010148 );
} );
test( "Test: \"NEGBINOMDIST\"", function () {
function negbinomdist( x, r, p ) {
x = parseInt( x );
......
......@@ -55,10 +55,8 @@
cFormulaFunctionGroup['TextAndData'] = cFormulaFunctionGroup['TextAndData'] || [];
cFormulaFunctionGroup['TextAndData'].push(cDBCS, cUNICHAR, cUNICODE);
cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || [];
cFormulaFunctionGroup['Statistical'].push(cBINOM_DIST_RANGE,
cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT, cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT,
cHYPGEOM_DIST, cNEGBINOM_DIST, cNORM_S_DIST,
cPERMUTATIONA, cPHI);
cFormulaFunctionGroup['Statistical'].push(cBINOM_DIST_RANGE, cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT,
cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cHYPGEOM_DIST, cNEGBINOM_DIST, cPERMUTATIONA, cPHI);
cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || [];
cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI);
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
......@@ -71,9 +69,8 @@
cFormulaFunctionGroup['NotRealised'] = cFormulaFunctionGroup['NotRealised'] || [];
cFormulaFunctionGroup['NotRealised'].push(cDAYS, cISOWEEKNUM, cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR,
cDBCS, cUNICHAR, cUNICODE, cBINOM_DIST_RANGE, cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT,
cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cHYPGEOM_DIST, cNEGBINOM_DIST,
cNORM_S_DIST, cPERMUTATIONA, cPHI, cPDURATION, cRRI, cAGGREGATE, cMUNIT, cFORMULATEXT, cISFORMULA,
cSHEET, cSHEETS);
cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cHYPGEOM_DIST, cNEGBINOM_DIST, cPERMUTATIONA, cPHI, cPDURATION,
cRRI, cAGGREGATE, cMUNIT, cFORMULATEXT, cISFORMULA, cSHEET, cSHEETS);
/**
* @constructor
......@@ -339,18 +336,6 @@
cNEGBINOM_DIST.prototype = Object.create(cBaseFunction.prototype);
cNEGBINOM_DIST.prototype.constructor = cNEGBINOM_DIST;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cNORM_S_DIST() {
cBaseFunction.call(this, "NORM.S.DIST");
this.isXLFN = true;
}
cNORM_S_DIST.prototype = Object.create(cBaseFunction.prototype);
cNORM_S_DIST.prototype.constructor = cNORM_S_DIST;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -68,8 +68,8 @@
cFORECAST_LINEAR, 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,
cMODE_MULT, cMODE_SNGL, cNEGBINOMDIST, cNORMDIST, cNORM_DIST, cNORMINV, cNORM_INV, cNORMSDIST, cNORMSINV,
cNORM_S_INV, cPEARSON, cPERCENTILE, cPERCENTILE_EXC, cPERCENTILE_INC, cPERCENTRANK, cPERCENTRANK_EXC,
cMODE_MULT, cMODE_SNGL, cNEGBINOMDIST, cNORMDIST, cNORM_DIST, cNORMINV, cNORM_INV, cNORMSDIST, cNORM_S_DIST,
cNORMSINV, cNORM_S_INV, cPEARSON, cPERCENTILE, cPERCENTILE_EXC, cPERCENTILE_INC, cPERCENTRANK, cPERCENTRANK_EXC,
cPERCENTRANK_INC, cPERMUT, cPOISSON, cPOISSON_DIST, cPROB, cQUARTILE, cQUARTILE_EXC, cQUARTILE_INC, cRANK,
cRANK_AVG, cRANK_EQ, cRSQ, cSKEW, cSKEW_P, cSLOPE, cSMALL, cSTANDARDIZE, cSTDEV, cSTDEV_S, cSTDEVA, cSTDEVP,
cSTDEV_P, cSTDEVPA, cSTEYX, cTDIST, cT_DIST, cT_DIST_2T, cT_DIST_RT, cT_INV, cT_INV_2T, cTINV, cTREND,
......@@ -5569,6 +5569,50 @@
return this.value = arg0;
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cNORM_S_DIST() {
this.name = "NORM.S.DIST";
this.value = null;
this.argumentsCurrent = 0;
}
cNORM_S_DIST.prototype = Object.create(cBaseFunction.prototype);
cNORM_S_DIST.prototype.constructor = cNORM_S_DIST;
cNORM_S_DIST.prototype.argumentsMin = 2;
cNORM_S_DIST.prototype.argumentsMax = 2;
cNORM_S_DIST.prototype.isXLFN = true;
cNORM_S_DIST.prototype.numFormat = AscCommonExcel.cNumFormatNone;
cNORM_S_DIST.prototype.Calculate = function (arg) {
function normDistCalc(argArray) {
var arg0 = argArray[0], arg1 = argArray[1];
var res;
if(arg1){
res = 0.5 + gauss(arg0);
}else{
res = Math.exp( - Math.pow( arg0, 2 ) / 2 ) / Math.sqrt( 2 * Math.PI );
}
return isNaN(res) ? new cError(cErrorType.not_numeric) : new cNumber(res);
}
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;
}
return this.value = this._findArrayInNumberArguments(oArguments, normDistCalc);
};
/**
* @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