Commit e58276ea authored by GoshaZotov's avatar GoshaZotov

add formulas: T.DIST.2T / T.DIST.RT

parent 5f022df4
......@@ -967,6 +967,24 @@ $( function () {
strictEqual( oParser.calculate().getValue().toFixed(8) - 0, 0.00073691, "T.DIST(8,3,FALSE)" );
} );
test( "Test: \"T.DIST.2T\"", function () {
ws.getRange2( "A2" ).setValue( "1.959999998" );
ws.getRange2( "A3" ).setValue( "60" );
oParser = new parserFormula( "T.DIST.2T(A2,A3)", "A1", ws );
ok( oParser.parse(), "T.DIST.2T(A2,A3)" );
strictEqual( oParser.calculate().getValue().toFixed(9) - 0, 0.054644930, "T.DIST.2T(A2,A3)" );
} );
test( "Test: \"T.DIST.RT\"", function () {
ws.getRange2( "A2" ).setValue( "1.959999998" );
ws.getRange2( "A3" ).setValue( "60" );
oParser = new parserFormula( "T.DIST.RT(A2,A3)", "A1", ws );
ok( oParser.parse(), "T.DIST.RT(A2,A3)" );
strictEqual( oParser.calculate().getValue().toFixed(6) - 0, 0.027322, "T.DIST.RT(A2,A3)" );
} );
test( "Test: \"SUM(1,2,3)\"", function () {
oParser = new parserFormula( 'SUM(1,2,3)', "A1", ws );
ok( oParser.parse() );
......
......@@ -66,8 +66,8 @@
cFTEST, cGAMMADIST, cGAMMAINV, cGAMMALN, cGEOMEAN, cGROWTH, cHARMEAN, cHYPGEOMDIST, cINTERCEPT, cKURT, cLARGE,
cLINEST, cLOGEST, cLOGINV, cLOGNORMDIST, cMAX, cMAXA, cMEDIAN, cMIN, cMINA, cMODE, cNEGBINOMDIST, cNORMDIST,
cNORMINV, cNORMSDIST, cNORMSINV, cPEARSON, cPERCENTILE, cPERCENTRANK, cPERMUT, cPOISSON, cPROB, cQUARTILE,
cRANK, cRSQ, cSKEW, cSLOPE, cSMALL, cSTANDARDIZE, cSTDEV, cSTDEVA, cSTDEVP, cSTDEVPA, cSTEYX, cTDIST, cT_DIST, cTINV,
cTREND, cTRIMMEAN, cTTEST, cVAR, cVARA, cVARP, cVARPA, cWEIBULL, cZTEST);
cRANK, cRSQ, cSKEW, cSLOPE, cSMALL, cSTANDARDIZE, cSTDEV, cSTDEVA, cSTDEVP, cSTDEVPA, cSTEYX, cTDIST, cT_DIST,
cT_DIST_2T, cT_DIST_RT, cTINV, cTREND, cTRIMMEAN, cTTEST, cVAR, cVARA, cVARP, cVARPA, cWEIBULL, cZTEST);
function integralPhi(x) { // Using gauss(x)+0.5 has severe cancellation errors for x<-4
return 0.5 * AscCommonExcel.rtl_math_erfc(-x * 0.7071067811865475); // * 1/sqrt(2)
......@@ -5317,6 +5317,98 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cT_DIST_2T() {
cBaseFunction.call(this, "T.DIST.2T");
}
cT_DIST_2T.prototype = Object.create(cBaseFunction.prototype);
cT_DIST_2T.prototype.constructor = cT_DIST_2T;
cT_DIST_2T.prototype.argumentsMin = 2;
cT_DIST_2T.prototype.argumentsMax = 2;
cT_DIST_2T.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 T = argArray[0];
var fDF = argArray[1];
if (fDF < 1 || T < 0){
return new cError(cErrorType.not_numeric);
}
var res = getTDist(T, fDF, 2);
return null !== res && !isNaN(res) ? new cNumber(res) : new cError(cErrorType.wrong_value_type);
};
return this.value = this._findArrayInNumberArguments(oArguments, calcTDist);
};
cT_DIST_2T.prototype.getInfo = function () {
return {
name: this.name, args: "(x, deg_freedom)"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cT_DIST_RT() {
cBaseFunction.call(this, "T.DIST.RT");
}
cT_DIST_RT.prototype = Object.create(cBaseFunction.prototype);
cT_DIST_RT.prototype.constructor = cT_DIST_RT;
cT_DIST_RT.prototype.argumentsMin = 2;
cT_DIST_RT.prototype.argumentsMax = 2;
cT_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 T = argArray[0];
var fDF = argArray[1];
if (fDF < 1){
return new cError(cErrorType.not_numeric);
}
var res = getTDist(T, fDF, 1);
if ( T < 0 ){
res = 1 - res;
}
return null !== res && !isNaN(res) ? new cNumber(res) : new cError(cErrorType.wrong_value_type);
};
return this.value = this._findArrayInNumberArguments(oArguments, calcTDist);
};
cT_DIST_RT.prototype.getInfo = function () {
return {
name: this.name, args: "(x, deg_freedom)"
};
};
/**
* @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