@@ -73,35 +73,35 @@ public double getLogLikelihoodForParameters(final double[] parameters)
73
73
double logLikelihood = 0.0 ;
74
74
75
75
final double volScaling = 1 ;
76
- double evalPrev = 0.0 ;
77
- double eval = volScaling * (Math .log ((timeSeries .getValue (1 ))/(timeSeries .getValue (0 ))));
78
- if (Double .isInfinite (eval ) || Double .isNaN (eval )) {
79
- eval = 0 ;
76
+ double evaluationPrev = 0.0 ;
77
+ double evaluation = volScaling * (Math .log ((timeSeries .getValue (1 ))/(timeSeries .getValue (0 ))));
78
+ if (Double .isInfinite (evaluation ) || Double .isNaN (evaluation )) {
79
+ evaluation = 0 ;
80
80
}
81
81
double h = omega / (1.0 - alpha - beta );
82
82
double m = 0.0 ; // xxx how to init?
83
83
84
- logLikelihood += - Math .log (h ) - 2 * Math .log ((Math .abs (timeSeries .getValue (1 )))/volScaling ) - eval * eval / h ;
84
+ logLikelihood += - Math .log (h ) - 2 * Math .log ((Math .abs (timeSeries .getValue (1 )))/volScaling ) - evaluation * evaluation / h ;
85
85
86
86
final int length = timeSeries .getNumberOfTimePoints ();
87
87
for (int i = 1 ; i < length -1 ; i ++) {
88
- m = -mu -theta * m + eval - phi * evalPrev ;
88
+ m = -mu -theta * m + evaluation - phi * evaluationPrev ;
89
89
h = (omega + alpha * m * m ) + beta * h ;
90
90
91
- final double value1 = timeSeries .getValue (i );
92
- final double value2 = timeSeries .getValue (i +1 );
91
+ final double currentValue = timeSeries .getValue (i );
92
+ final double nextValue = timeSeries .getValue (i +1 );
93
93
94
- double evalNext = volScaling * (Math .log ((value2 )/(value1 )));
94
+ double evalNext = volScaling * (Math .log ((nextValue )/(currentValue )));
95
95
if (Double .isInfinite (evalNext ) || Double .isNaN (evalNext )) {
96
96
evalNext = 0 ;
97
97
}
98
- final double mNext = -mu - theta * m + evalNext - phi * eval ;
98
+ final double mNext = -mu - theta * m + evalNext - phi * evaluation ;
99
99
100
100
// We need to take abs here, which corresponds to the assumption that -x is lognormal, given that we encounter a negative values.
101
- logLikelihood += - Math .log (h ) - 2 * Math .log ((Math .abs (value2 ))/volScaling ) - mNext * mNext / h ;
101
+ logLikelihood += - Math .log (h ) - 2 * Math .log ((Math .abs (nextValue ))/volScaling ) - mNext * mNext / h ;
102
102
103
- evalPrev = eval ;
104
- eval = evalNext ;
103
+ evaluationPrev = evaluation ;
104
+ evaluation = evalNext ;
105
105
}
106
106
logLikelihood += - Math .log (2 * Math .PI ) * (length -1 );
107
107
logLikelihood *= 0.5 ;
0 commit comments