Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
19921dbe
Commit
19921dbe
authored
Aug 24, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function for FORECAST.ETS's functions
parent
f2a2c5f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
205 additions
and
5 deletions
+205
-5
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+205
-5
No files found.
cell/model/FormulaObjects/statisticalFunctions.js
View file @
19921dbe
...
...
@@ -66,11 +66,11 @@
cCHISQ_DIST_RT
,
cCHISQ_INV
,
cCHISQ_INV_RT
,
cCHITEST
,
cCHISQ_TEST
,
cCONFIDENCE
,
cCONFIDENCE_NORM
,
cCONFIDENCE_T
,
cCORREL
,
cCOUNT
,
cCOUNTA
,
cCOUNTBLANK
,
cCOUNTIF
,
cCOUNTIFS
,
cCOVAR
,
cCOVARIANCE_P
,
cCOVARIANCE_S
,
cCRITBINOM
,
cDEVSQ
,
cEXPON_DIST
,
cEXPONDIST
,
cF_DIST
,
cFDIST
,
cF_DIST_RT
,
cF_INV
,
cFINV
,
cF_INV_RT
,
cFISHER
,
cFISHERINV
,
cFORECAST
,
cFORECAST_
LINEAR
,
cFREQUENCY
,
cFTEST
,
cGAMMA
,
cGAMMA_DIST
,
cGAMMADIST
,
cGAMMA_INV
,
cGAMMA
INV
,
cGAMMA
LN
,
cGAMMALN_PRECISE
,
cGAUSS
,
cGEOMEAN
,
cGROWTH
,
cHARMEAN
,
cHYPGEOMDIST
,
cINTERCEPT
,
cKURT
,
cLARGE
,
cL
INEST
,
cLOGEST
,
cLOGINV
,
cLOGNORM_DIST
,
cLOGNORM_INV
,
cLOGNORMDIST
,
cMAX
,
cMAXA
,
cMAXIFS
,
cMEDIAN
,
cMI
N
,
cMIN
A
,
cMINIFS
,
cMODE
,
cMODE_MULT
,
cMODE_SNGL
,
cNEGBINOMDIST
,
cNEGBINOM_DIST
,
cNORMDIST
,
cNORM_DIST
,
cNORMINV
,
cNORM_INV
,
cNORMSDIST
,
cNORM_S_DIST
,
cNORMSINV
,
cNORM_S_INV
,
cPEARSON
,
cPERCENTILE
,
cPERCENTILE_EXC
,
cFORECAST
,
cFORECAST_
ETS
,
cFORECAST_LINEAR
,
cFREQUENCY
,
cFTEST
,
cGAMMA
,
cGAMMA_DIST
,
cGAMMADIST
,
cGAMMA_
INV
,
cGAMMA
INV
,
cGAMMALN
,
cGAMMALN_PRECISE
,
cGAUSS
,
cGEOMEAN
,
cGROWTH
,
cHARMEAN
,
cHYPGEOMDIST
,
cINTERCEPT
,
cKURT
,
cL
ARGE
,
cLINEST
,
cLOGEST
,
cLOGINV
,
cLOGNORM_DIST
,
cLOGNORM_INV
,
cLOGNORMDIST
,
cMAX
,
cMAXA
,
cMAXIFS
,
cMEDIA
N
,
cMIN
,
cMINA
,
cMINIFS
,
cMODE
,
cMODE_MULT
,
cMODE_SNGL
,
cNEGBINOMDIST
,
cNEGBINOM_DIST
,
cNORMDIST
,
cNORM_DIST
,
cNORM
INV
,
cNORM
_INV
,
cNORMSDIST
,
cNORM_S_DIST
,
cNORMSINV
,
cNORM_S_INV
,
cPEARSON
,
cPERCENTILE
,
cPERCENTILE_EXC
,
cPERCENTILE_INC
,
cPERCENTRANK
,
cPERCENTRANK_EXC
,
cPERCENTRANK_INC
,
cPERMUT
,
cPERMUTATIONA
,
cPHI
,
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
,
...
...
@@ -3731,6 +3731,206 @@
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cFORECAST_ETS
()
{
this
.
name
=
"
FORECAST.ETS
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cFORECAST_ETS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cFORECAST_ETS
.
prototype
.
constructor
=
cFORECAST_ETS
;
cFORECAST_ETS
.
prototype
.
argumentsMin
=
3
;
cFORECAST_ETS
.
prototype
.
argumentsMax
=
6
;
cFORECAST_ETS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
oArguments
=
this
.
_prepareArguments
(
arg
,
arguments
[
1
],
true
,
[
null
,
cElementType
.
array
,
cElementType
.
array
]);
var
argClone
=
oArguments
.
args
;
argClone
[
3
]
=
argClone
[
3
]
?
argClone
[
3
].
tocNumber
()
:
new
cNumber
(
1
);
argClone
[
4
]
=
argClone
[
4
]
?
argClone
[
4
].
tocNumber
()
:
new
cNumber
(
1
);
argClone
[
5
]
=
argClone
[
5
]
?
argClone
[
5
].
tocNumber
()
:
new
cNumber
(
1
);
var
calcFunc
=
function
(
argArray
){
var
pTMat
=
argArray
[
0
];
var
pMatY
=
argArray
[
1
];
var
pMatX
=
argArray
[
2
];
var
nSmplInPrd
=
argArray
[
3
];
var
bDataCompletion
=
argArray
[
4
];
var
nAggregation
=
argArray
[
5
];
if
(
!
pMatX
||
!
pMatY
)
{
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
var
nCX
=
pMatX
.
length
;
var
nCY
=
pMatY
.
length
;
var
nRX
=
pMatX
[
0
].
length
;
var
nRY
=
pMatY
[
0
].
length
;
if
(
nRX
!==
nRY
||
nCX
!==
nCY
)
{
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
if
(
Math
.
fmod
(
nSmplInPrd
,
1.0
)
!==
0
||
nSmplInPrd
<
0.0
)
{
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
// maRange needs to be sorted by X
var
mnCount
=
pMatX
.
length
;
var
maRange
=
[];
for
(
var
i
=
0
;
i
<
mnCount
;
i
++
){
maRange
.
push
(
{
X
:
pMatX
[
i
][
0
].
value
,
Y
:
pMatY
[
i
][
0
].
value
}
);
}
maRange
.
sort
(
function
(
a
,
b
)
{
return
a
.
X
-
b
.
X
;
});
if
(
pTMat
)
{
if
(
pTMat
[
0
]
<
maRange
[
0
].
X
)
{
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
/*// Month intervals don't have exact stepsize, so first
// detect if month interval is used.
// Method: assume there is an month interval and verify.
// If month interval is used, replace maRange.X with month values
// for ease of calculations.
Date aNullDate = *( mpFormatter->GetNullDate() );
Date aDate = aNullDate + static_cast< long >( maRange[ 0 ].X );
mnMonthDay = aDate.GetDay();
for ( SCSIZE i = 1; i < mnCount && mnMonthDay; i++ )
{
Date aDate1 = aNullDate + static_cast< long >( maRange[ i ].X );
if ( aDate != aDate1 )
{
if ( aDate1.GetDay() != mnMonthDay )
mnMonthDay = 0;
}
}
var aNullDate = ;
var mnMonthDay = 1;
mfStepSize = ::std::numeric_limits<double>::max();
if ( mnMonthDay )
{
for ( SCSIZE i = 0; i < mnCount; i++ )
{
aDate = aNullDate + static_cast< long >( maRange[ i ].X );
maRange[ i ].X = aDate.GetYear() * 12 + aDate.GetMonth();
}
}*/
/*for ( var i = 1; i < mnCount; i++ )
{
var fStep = maRange[ i ].X - maRange[ i - 1 ].X;
if ( fStep === 0.0 )
{
if ( nAggregation === 0 )
{
return new cError(cErrorType.wrong_value_type);
}
var fTmp = maRange[ i - 1 ].Y;
var nCounter = 1;
switch ( nAggregation )
{
case 1 : // AVERAGE (default)
while ( i < mnCount && maRange[ i ].X === maRange[ i - 1 ].X )
{
maRange.erase( maRange.begin() + i );
--mnCount;
}
break;
case 7 : // SUM
while ( i < mnCount && maRange[ i ].X === maRange[ i - 1 ].X )
{
fTmp += maRange[ i ].Y;
maRange.erase( maRange.begin() + i );
--mnCount;
}
maRange[ i - 1 ].Y = fTmp;
break;
case 2 : // COUNT
case 3 : // COUNTA (same as COUNT as there are no non-numeric Y-values)
while ( i < mnCount && maRange[ i ].X === maRange[ i - 1 ].X )
{
nCounter++;
maRange.erase( maRange.begin() + i );
--mnCount;
}
maRange[ i - 1 ].Y = nCounter;
break;
case 4 : // MAX
while ( i < mnCount && maRange[ i ].X === maRange[ i - 1 ].X )
{
if ( maRange[ i ].Y > fTmp )
fTmp = maRange[ i ].Y;
maRange.erase( maRange.begin() + i );
--mnCount;
}
maRange[ i - 1 ].Y = fTmp;
break;
case 5 : // MEDIAN
{
std::vector< double > aTmp;
aTmp.push_back( maRange[ i - 1 ].Y );
while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X )
{
aTmp.push_back( maRange[ i ].Y );
nCounter++;
maRange.erase( maRange.begin() + i );
--mnCount;
}
sort( aTmp.begin(), aTmp.end() );
if ( nCounter % 2 )
maRange[ i - 1 ].Y = aTmp[ nCounter / 2 ];
else
maRange[ i - 1 ].Y = ( aTmp[ nCounter / 2 ] + aTmp[ nCounter / 2 - 1 ] ) / 2.0;
}
break;
case 6 : // MIN
while ( i < mnCount && maRange[ i ].X === maRange[ i - 1 ].X )
{
if ( maRange[ i ].Y < fTmp )
fTmp = maRange[ i ].Y;
maRange.erase( maRange.begin() + i );
--mnCount;
}
maRange[ i - 1 ].Y = fTmp;
break;
}
if ( i < mnCount - 1 )
fStep = maRange[ i ].X - maRange[ i - 1 ].X;
else
fStep = mfStepSize;
}
if ( fStep > 0 && fStep < mfStepSize )
mfStepSize = fStep;
}*/
return
new
cNumber
(
1
);
};
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calcFunc
);
};
/**
* @constructor
* @extends {cFORECAST}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment