Commit 5b57871a authored by GoshaZotov's avatar GoshaZotov

add CHISQ.DIST.RT formula

parent b54d5e82
...@@ -1065,6 +1065,15 @@ $( function () { ...@@ -1065,6 +1065,15 @@ $( function () {
strictEqual( oParser.calculate().getValue().toFixed(7) - 0, 0.0500006, "CHIDIST(A2,A3)" ); strictEqual( oParser.calculate().getValue().toFixed(7) - 0, 0.0500006, "CHIDIST(A2,A3)" );
} ); } );
test( "Test: \"CHISQ.DIST.RT\"", function () {
ws.getRange2( "A2" ).setValue( "18.307" );
ws.getRange2( "A3" ).setValue( "10" );
oParser = new parserFormula( "CHISQ.DIST.RT(A2,A3)", "A1", ws );
ok( oParser.parse(), "CHISQ.DIST.RT(A2,A3)" );
strictEqual( oParser.calculate().getValue().toFixed(7) - 0, 0.0500006, "CHISQ.DIST.RT(A2,A3)" );
} );
test( "Test: \"CHISQ.DIST\"", function () { test( "Test: \"CHISQ.DIST\"", function () {
oParser = new parserFormula( "CHISQ.DIST(0.5,1,TRUE)", "A1", ws ); oParser = new parserFormula( "CHISQ.DIST(0.5,1,TRUE)", "A1", ws );
ok( oParser.parse(), "CHISQ.DIST(0.5,1,TRUE)" ); ok( oParser.parse(), "CHISQ.DIST(0.5,1,TRUE)" );
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || []; cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || [];
cFormulaFunctionGroup['Statistical'].push(cAVEDEV, cAVERAGE, cAVERAGEA, cAVERAGEIF, cAVERAGEIFS, cBETADIST, cBETA_DIST, cFormulaFunctionGroup['Statistical'].push(cAVEDEV, cAVERAGE, cAVERAGEA, cAVERAGEIF, cAVERAGEIFS, cBETADIST, cBETA_DIST,
cBETA_INV, cBINOMDIST, cCHIDIST, cCHIINV, cCHISQ_DIST, cCHITEST, cCONFIDENCE, cCORREL, cCOUNT, cCOUNTA, cCOUNTBLANK, cCOUNTIF, cBETA_INV, cBINOMDIST, cCHIDIST, cCHIINV, cCHISQ_DIST, cCHISQ_DIST_RT, cCHITEST, cCONFIDENCE, cCORREL, cCOUNT, cCOUNTA, cCOUNTBLANK, cCOUNTIF,
cCOUNTIFS, cCOVAR, cCRITBINOM, cDEVSQ, cEXPONDIST, cFDIST, cF_DIST, cF_DIST_RT, cFINV, cFISHER, cFISHERINV, cFORECAST, cFREQUENCY, cCOUNTIFS, cCOVAR, cCRITBINOM, cDEVSQ, cEXPONDIST, cFDIST, cF_DIST, cF_DIST_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, cLOGNORMDIST, cMAX, cMAXA, cMEDIAN, cMIN, cMINA, cMODE, cNEGBINOMDIST, cNORMDIST,
...@@ -1734,6 +1734,51 @@ ...@@ -1734,6 +1734,51 @@
}; };
}; };
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
//clone cCHIDIST function
function cCHISQ_DIST_RT() {
cBaseFunction.call(this, "CHISQ.DIST.RT");
}
cCHISQ_DIST_RT.prototype = Object.create(cBaseFunction.prototype);
cCHISQ_DIST_RT.prototype.constructor = cCHISQ_DIST_RT;
cCHISQ_DIST_RT.prototype.argumentsMin = 2;
cCHISQ_DIST_RT.prototype.argumentsMax = 2;
cCHISQ_DIST_RT.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();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
var calcTDist = function(argArray){
var fChi = argArray[0];
var fDF = parseInt(argArray[1]);
if ( fDF < 1 || fChi < 0 || fDF > Math.pow(10, 10)){
return new cError(cErrorType.not_numeric);
}
var res = getChiDist( fChi, fDF);
return null !== res && !isNaN(res) ? new cNumber(res) : new cError(cErrorType.wrong_value_type);
};
return this.value = this._findArrayInNumberArguments(oArguments, calcTDist);
};
cCHISQ_DIST_RT.prototype.getInfo = function () {
return {
name: this.name, args: "(x, deg_freedom)"
};
};
/** /**
* @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