Commit 4e9597f2 authored by GoshaZotov's avatar GoshaZotov

add LOGNORM.DIST formula

parent ab3241de
...@@ -1054,23 +1054,18 @@ $( function () { ...@@ -1054,23 +1054,18 @@ $( function () {
strictEqual( oParser.calculate().getValue().toFixed(6) - 0, 0.606533, "T.INV.2T(A2,A3)" ); strictEqual( oParser.calculate().getValue().toFixed(6) - 0, 0.606533, "T.INV.2T(A2,A3)" );
} ); } );
test( "Test: \"GAMMA\"", function () { test( "Test: \"LOGNORM.DIST\"", function () {
oParser = new parserFormula( "GAMMA(2.5)", "A1", ws ); ws.getRange2( "A2" ).setValue( "4" );
ok( oParser.parse(), "GAMMA(2.5)" ); ws.getRange2( "A3" ).setValue( "3.5" );
strictEqual( oParser.calculate().getValue().toFixed(3) - 0, 1.329, "GAMMA(2.5)" ); ws.getRange2( "A4" ).setValue( "1.2" );
oParser = new parserFormula( "GAMMA(-3.75)", "A1", ws ); oParser = new parserFormula( "LOGNORM.DIST(A2,A3,A4,TRUE)", "A1", ws );
ok( oParser.parse(), "GAMMA(-3.75)" ); ok( oParser.parse(), "LOGNORM.DIST(A2,A3,A4,TRUE)" );
strictEqual( oParser.calculate().getValue().toFixed(3) - 0, 0.268, "GAMMA(0.268)" ); strictEqual( oParser.calculate().getValue().toFixed(7) - 0, 0.0390836, "LOGNORM.DIST(A2,A3,A4,TRUE)" );
oParser = new parserFormula( "GAMMA(0)", "A1", ws ); oParser = new parserFormula( "LOGNORM.DIST(A2,A3,A4,FALSE)", "A1", ws );
ok( oParser.parse(), "GAMMA(0)" ); ok( oParser.parse(), "LOGNORM.DIST(A2,A3,A4,FALSE)" );
strictEqual( oParser.calculate().getValue(), "#NUM!", "GAMMA(0)" ); strictEqual( oParser.calculate().getValue().toFixed(7) - 0, 0.0176176, "LOGNORM.DIST(A2,A3,A4,FALSE)" );
oParser = new parserFormula( "GAMMA(-2)", "A1", ws );
ok( oParser.parse(), "GAMMA(-2)" );
strictEqual( oParser.calculate().getValue(), "#NUM!", "GAMMA(-2)" );
} ); } );
test( "Test: \"GAMMA.DIST\"", function () { test( "Test: \"GAMMA.DIST\"", function () {
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
cBETA_INV, cBINOMDIST, cCHIDIST, cCHIINV, cCHISQ_DIST, cCHISQ_DIST_RT, cCHISQ_INV, cCHISQ_INV_RT, cCHITEST, cCONFIDENCE, cCORREL, cCOUNT, cCOUNTA, cCOUNTBLANK, cCOUNTIF, cBETA_INV, cBINOMDIST, cCHIDIST, cCHIINV, cCHISQ_DIST, cCHISQ_DIST_RT, cCHISQ_INV, cCHISQ_INV_RT, cCHITEST, cCONFIDENCE, cCORREL, cCOUNT, cCOUNTA, cCOUNTBLANK, cCOUNTIF,
cCOUNTIFS, cCOVAR, cCRITBINOM, cDEVSQ, cEXPONDIST, cFDIST, cF_DIST, cF_DIST_RT, cF_INV, cF_INV_RT, cFINV, cFISHER, cFISHERINV, cFORECAST, cFREQUENCY, cCOUNTIFS, cCOVAR, cCRITBINOM, cDEVSQ, cEXPONDIST, cFDIST, cF_DIST, cF_DIST_RT, cF_INV, cF_INV_RT, cFINV, cFISHER, cFISHERINV, cFORECAST, cFREQUENCY,
cFTEST, cGAMMA, cGAMMADIST, cGAMMAINV, cGAMMA_DIST, cGAMMA_INV, cGAMMALN, cGAMMALN_PRECISE, cGEOMEAN, cGROWTH, cHARMEAN, cHYPGEOMDIST, cINTERCEPT, cKURT, cLARGE, cFTEST, cGAMMA, cGAMMADIST, cGAMMAINV, cGAMMA_DIST, cGAMMA_INV, cGAMMALN, cGAMMALN_PRECISE, cGEOMEAN, cGROWTH, cHARMEAN, cHYPGEOMDIST, cINTERCEPT, cKURT, cLARGE,
cLINEST, cLOGEST, cLOGINV, cLOGNORMDIST, cMAX, cMAXA, cMEDIAN, cMIN, cMINA, cMODE, cNEGBINOMDIST, cNORMDIST, cLINEST, cLOGEST, cLOGINV, cLOGNORM_DIST, cLOGNORMDIST, cMAX, cMAXA, cMEDIAN, cMIN, cMINA, cMODE, cNEGBINOMDIST, cNORMDIST,
cNORMINV, cNORMSDIST, cNORMSINV, cPEARSON, cPERCENTILE, cPERCENTRANK, cPERMUT, cPOISSON, cPROB, cQUARTILE, cNORMINV, cNORMSDIST, cNORMSINV, cPEARSON, cPERCENTILE, cPERCENTRANK, cPERMUT, cPOISSON, cPROB, cQUARTILE,
cRANK, cRSQ, cSKEW, cSLOPE, cSMALL, cSTANDARDIZE, cSTDEV, cSTDEVA, cSTDEVP, cSTDEVPA, cSTEYX, cTDIST, cT_DIST, cRANK, 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); cT_DIST_2T, cT_DIST_RT, cT_INV, cT_INV_2T, cTINV, cTREND, cTRIMMEAN, cTTEST, cVAR, cVARA, cVARP, cVARPA, cWEIBULL, cZTEST);
...@@ -4201,6 +4201,69 @@ ...@@ -4201,6 +4201,69 @@
}; };
}; };
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cLOGNORM_DIST() {
this.name = "LOGNORM.DIST";
this.value = null;
this.argumentsCurrent = 0;
}
cLOGNORM_DIST.prototype = Object.create(cBaseFunction.prototype);
cLOGNORM_DIST.prototype.constructor = cLOGNORM_DIST;
cLOGNORM_DIST.prototype.argumentsMin = 4;
cLOGNORM_DIST.prototype.argumentsMax = 4;
cLOGNORM_DIST.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();
argClone[2] = argClone[2].tocNumber();
argClone[3] = argClone[3].tocNumber();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
var normdist = function(argArray){
var x = argArray[0];
var mue = argArray[1];
var sigma = argArray[2];
var bCumulative = argArray[3];
var res = null;
if (sigma <= 0.0)
{
return new cError(cErrorType.not_numeric);
}
if (bCumulative) {
if (x <= 0){
res = 0;
}else{
res = 0.5 + gauss((Math.ln(x) - mue) / sigma);
}
}
else{
if (x <= 0){
return new cError(cErrorType.not_numeric);
}else{
res = phi((Math.log(x) - mue) / sigma) / sigma / x;
}
}
return null !== res && !isNaN(res) ? new cNumber(res) : new cError(cErrorType.wrong_value_type);
};
return this.value = this._findArrayInNumberArguments(oArguments, normdist);
};
cLOGNORM_DIST.prototype.getInfo = function () {
return {name: this.name, args: "( x , mean , standard-deviation, cumulative )"}
};
/** /**
* @constructor * @constructor
* @extends {AscCommonExcel.cBaseFunction} * @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