Commit 1bf2b146 authored by GoshaZotov's avatar GoshaZotov

add CONFIDENCE.NORM/CONFIDENCE.T formulas

modify CONFIDENCE
parent 418b3393
...@@ -56,15 +56,11 @@ ...@@ -56,15 +56,11 @@
cFormulaFunctionGroup['TextAndData'] = cFormulaFunctionGroup['TextAndData'] || []; cFormulaFunctionGroup['TextAndData'] = cFormulaFunctionGroup['TextAndData'] || [];
cFormulaFunctionGroup['TextAndData'].push(cDBCS, cUNICHAR, cUNICODE); cFormulaFunctionGroup['TextAndData'].push(cDBCS, cUNICHAR, cUNICODE);
cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || []; cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || [];
cFormulaFunctionGroup['Statistical'].push(cBINOM_DIST, cBINOM_DIST_RANGE, cBINOM_INV, cFormulaFunctionGroup['Statistical'].push(cBINOM_DIST, cBINOM_DIST_RANGE, cBINOM_INV, cCHISQ_TEST, cCOVARIANCE_P,
cCHISQ_TEST, cCONFIDENCE_NORM, cCONFIDENCE_T, cCOVARIANCE_S, cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT, cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT,
cCOVARIANCE_P, cCOVARIANCE_S, cF_TEST, cFORECAST_ETS, cFORECAST_LINEAR, cHYPGEOM_DIST, cMODE_MULT, cMODE_SNGL, cNEGBINOM_DIST, cNORM_DIST, cNORM_INV, cNORM_S_DIST,
cFORECAST_ETS_CONFINT, cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cFORECAST_LINEAR, cNORM_S_INV, cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC, cSKEW_P, cSTDEV_P, cSTDEV_S,
cHYPGEOM_DIST, cMODE_MULT, cMODE_SNGL, cT_TEST, cVAR_P, cVAR_S, cWEIBULL_DIST, cZ_TEST);
cNEGBINOM_DIST, cNORM_DIST, cNORM_INV, cNORM_S_DIST, cNORM_S_INV,
cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC,
cSKEW_P, cSTDEV_P, cSTDEV_S, cT_TEST, cVAR_P,
cVAR_S, cWEIBULL_DIST, cZ_TEST);
cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || []; cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || [];
cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI); cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI);
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || []; cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
...@@ -77,12 +73,11 @@ ...@@ -77,12 +73,11 @@
cFormulaFunctionGroup['NotRealised'] = cFormulaFunctionGroup['NotRealised'] || []; cFormulaFunctionGroup['NotRealised'] = cFormulaFunctionGroup['NotRealised'] || [];
cFormulaFunctionGroup['NotRealised'].push(cDAYS, cISOWEEKNUM, cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR, cFormulaFunctionGroup['NotRealised'].push(cDAYS, cISOWEEKNUM, cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR,
cERF_PRECISE, cERFC_PRECISE, cDBCS, cUNICHAR, cUNICODE, cBINOM_DIST, cBINOM_DIST_RANGE, cBINOM_INV, cCHISQ_TEST, 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, cCOVARIANCE_P, cCOVARIANCE_S, cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT, cFORECAST_ETS_SEASONALITY,
cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cFORECAST_LINEAR, cHYPGEOM_DIST, cMODE_MULT, cMODE_SNGL, cFORECAST_ETS_STAT, cFORECAST_LINEAR, cHYPGEOM_DIST, cMODE_MULT, cMODE_SNGL, cNEGBINOM_DIST, cNORM_DIST,
cNEGBINOM_DIST, cNORM_DIST, cNORM_INV, cNORM_S_DIST, cNORM_S_INV, cNORM_INV, cNORM_S_DIST, cNORM_S_INV, cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC, cSKEW_P,
cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC, cSTDEV_P, cSTDEV_S, cT_TEST, cVAR_P, cVAR_S, cWEIBULL_DIST, cZ_TEST, cPDURATION, cRRI, cAGGREGATE, cMUNIT,
cSKEW_P, cSTDEV_P, cSTDEV_S, cT_TEST, cVAR_P, cVAR_S, cWEIBULL_DIST, cZ_TEST, cPDURATION, cRRI, cFORMULATEXT, cISFORMULA, cSHEET, cSHEETS);
cAGGREGATE, cMUNIT, cFORMULATEXT, cISFORMULA, cSHEET, cSHEETS);
/** /**
* @constructor * @constructor
...@@ -216,30 +211,6 @@ ...@@ -216,30 +211,6 @@
cCOMBINA.prototype = Object.create(cBaseFunction.prototype); cCOMBINA.prototype = Object.create(cBaseFunction.prototype);
cCOMBINA.prototype.constructor = cCOMBINA; cCOMBINA.prototype.constructor = cCOMBINA;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCONFIDENCE_NORM() {
cBaseFunction.call(this, "CONFIDENCE.NORM");
this.isXLFN = true;
}
cCONFIDENCE_NORM.prototype = Object.create(cBaseFunction.prototype);
cCONFIDENCE_NORM.prototype.constructor = cCONFIDENCE_NORM;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCONFIDENCE_T() {
cBaseFunction.call(this, "CONFIDENCE.T");
this.isXLFN = true;
}
cCONFIDENCE_T.prototype = Object.create(cBaseFunction.prototype);
cCONFIDENCE_T.prototype.constructor = cCONFIDENCE_T;
/** /**
* @constructor * @constructor
* @extends {AscCommonExcel.cBaseFunction} * @extends {AscCommonExcel.cBaseFunction}
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || []; cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || [];
cFormulaFunctionGroup['Statistical'].push(cAVEDEV, cAVERAGE, cAVERAGEA, cAVERAGEIF, cAVERAGEIFS, cBETADIST, cFormulaFunctionGroup['Statistical'].push(cAVEDEV, cAVERAGE, cAVERAGEA, cAVERAGEIF, cAVERAGEIFS, cBETADIST,
cBETA_DIST, cBETA_INV, cBINOMDIST, cCHIDIST, cCHIINV, cCHISQ_DIST, cCHISQ_DIST_RT, cCHISQ_INV, cCHISQ_INV_RT, cBETA_DIST, 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, cCHITEST, cCONFIDENCE, cCONFIDENCE_NORM, cCONFIDENCE_T, cCORREL, cCOUNT, cCOUNTA, cCOUNTBLANK, cCOUNTIF, cCOUNTIFS, cCOVAR, cCRITBINOM, cDEVSQ,
cEXPON_DIST, cEXPONDIST, cF_DIST, cFDIST, cF_DIST_RT, cF_INV, cFINV, cF_INV_RT, cFISHER, cFISHERINV, cFORECAST, cEXPON_DIST, cEXPONDIST, cF_DIST, cFDIST, cF_DIST_RT, cF_INV, cFINV, cF_INV_RT, cFISHER, cFISHERINV, cFORECAST,
cFREQUENCY, cFTEST, cGAMMA, cGAMMA_DIST, cGAMMADIST, cGAMMA_INV, cGAMMAINV, cGAMMALN, cGAMMALN_PRECISE, cGAUSS, 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, cGEOMEAN, cGROWTH, cHARMEAN, cHYPGEOMDIST, cINTERCEPT, cKURT, cLARGE, cLINEST, cLOGEST, cLOGINV, cLOGNORM_DIST,
...@@ -1995,46 +1995,100 @@ ...@@ -1995,46 +1995,100 @@
cCONFIDENCE.prototype.argumentsMax = 3; cCONFIDENCE.prototype.argumentsMax = 3;
cCONFIDENCE.prototype.Calculate = function (arg) { cCONFIDENCE.prototype.Calculate = function (arg) {
var alpha = arg[0], stdev_sigma = arg[1], size = arg[2]; var oArguments = this._prepareArguments(arg, arguments[1], true);
if (alpha instanceof cArea || alpha instanceof cArea3D) { var argClone = oArguments.args;
alpha = alpha.cross(arguments[1]);
} else if (alpha instanceof cArray) { argClone[0] = argClone[0].tocNumber();
alpha = alpha.getElement(0); argClone[1] = argClone[1].tocNumber();
argClone[2] = argClone[2].tocNumber();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
} }
if (stdev_sigma instanceof cArea || stdev_sigma instanceof cArea3D) { var calcConfidence = function(argArray){
stdev_sigma = stdev_sigma.cross(arguments[1]); var alpha = argArray[0];
} else if (stdev_sigma instanceof cArray) { var stdev_sigma = argArray[1];
stdev_sigma = stdev_sigma.getElement(0); var size = parseInt(argArray[2]);
if (alpha <= 0 || alpha >= 1 || stdev_sigma <= 0 || size < 1) {
return new cError(cErrorType.not_numeric);
} }
if (size instanceof cArea || size instanceof cArea3D) { return new cNumber(gaussinv(1 - alpha / 2) * stdev_sigma / Math.sqrt(size));
size = size.cross(arguments[1]); };
} else if (size instanceof cArray) {
size = size.getElement(0); return this.value = this._findArrayInNumberArguments(oArguments, calcConfidence);
};
/**
* @constructor
* @extends {cCONFIDENCE}
*/
function cCONFIDENCE_NORM() {
cCONFIDENCE.call(this);
this.name = "CONFIDENCE.NORM";
} }
alpha = alpha.tocNumber(); cCONFIDENCE_NORM.prototype = Object.create(cCONFIDENCE.prototype);
stdev_sigma = stdev_sigma.tocNumber(); cCONFIDENCE_NORM.prototype.constructor = cCONFIDENCE_NORM;
size = size.tocNumber(); cCONFIDENCE_NORM.prototype.isXLFN = true;
if (alpha instanceof cError) { /**
return this.value = alpha; * @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCONFIDENCE_T() {
this.name = "CONFIDENCE.T";
this.value = null;
this.argumentsCurrent = 0;
} }
if (stdev_sigma instanceof cError) {
return this.value = stdev_sigma; cCONFIDENCE_T.prototype = Object.create(cBaseFunction.prototype);
cCONFIDENCE_T.prototype.constructor = cCONFIDENCE_T;
cCONFIDENCE_T.prototype.argumentsMin = 3;
cCONFIDENCE_T.prototype.argumentsMax = 3;
cCONFIDENCE_T.prototype.isXLFN = true;
cCONFIDENCE_T.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();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
} }
if (size instanceof cError) {
return this.value = size; var calcConfidence = function(argArray){
var alpha = argArray[0];
var stdev_sigma = argArray[1];
var size = parseInt(argArray[2]);
if (alpha <= 0 || alpha >= 1 || stdev_sigma <= 0 || size < 1) {
return new cError(cErrorType.not_numeric);
} }
if (alpha.getValue() <= 0 || alpha.getValue() >= 1 || stdev_sigma.getValue <= 0 || size.getValue() < 1) { //ScTDistFunction aFunc( *this, fAlpha, fSize, nType );
return this.value = new cError(cErrorType.not_numeric); //double fVal = lcl_IterateInverse( aFunc, fSize * 0.5, fSize, bConvError );
var aFunc = new TDISTFUNCTION(alpha, size - 1, 2);
var oVal = iterateInverse(aFunc, size * 0.5, size);
var bConvError = oVal.bError;
if (bConvError){
return new cError(cErrorType.not_numeric);
} }
return this.value = var res = (stdev_sigma * oVal.val) / Math.sqrt( size );
new cNumber(gaussinv(1.0 - alpha.getValue() / 2.0) * stdev_sigma.getValue() / Math.sqrt(size.getValue())); return new cNumber(res);
};
return this.value = this._findArrayInNumberArguments(oArguments, calcConfidence);
}; };
/** /**
...@@ -5212,7 +5266,7 @@ ...@@ -5212,7 +5266,7 @@
var argClone = oArguments.args; var argClone = oArguments.args;
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
argClone[2] = argClone[2] ? argClone[2] : new cNumber(3); argClone[2] = argClone[2] ? argClone[2].tocNumber() : new cNumber(3);
var argError; var argError;
if (argError = this._checkErrorArg(argClone)) { if (argError = this._checkErrorArg(argClone)) {
...@@ -5262,7 +5316,7 @@ ...@@ -5262,7 +5316,7 @@
var argClone = oArguments.args; var argClone = oArguments.args;
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
argClone[2] = argClone[2] ? argClone[2] : new cNumber(3); argClone[2] = argClone[2] ? argClone[2].tocNumber() : new cNumber(3);
var argError; var argError;
if (argError = this._checkErrorArg(argClone)) { if (argError = this._checkErrorArg(argClone)) {
......
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