Skip to content

Commit 1a9d930

Browse files
committed
Fixes bug in Kalman Filter
- The computation of W used ratio * V instead of (ratio * V)**2 - Updating the Kalman gain used V instead of V**2 - Thanks to Statkraft for finding the bugs
1 parent 48e9315 commit 1a9d930

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/KalmanFilter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ KalmanFilter::KalmanFilter(Variable::Type iVariable, const Options& iOptions) :
1414
mVariable(iVariable),
1515
mHourlyCorr(0.93),
1616
mV(2.0),
17-
mRatio(0.06),
17+
mRatio(0.15),
1818
mPinit(0.5),
1919
mElevGradient(-0.0065),
2020
mDim(8) {
@@ -122,7 +122,7 @@ vec2 KalmanFilter::getW() const {
122122
for(int j = 0; j < mDim; j++) {
123123
int diff = std::min(abs(i-j), mDim - abs(i-j));
124124
float weight = pow(mHourlyCorr, (float) diff*hoursBetween);
125-
mW[i][j] = weight * factor;
125+
mW[i][j] = weight * factor * factor;
126126
}
127127
// assert(mW[i][i] == 1);
128128
}
@@ -231,7 +231,7 @@ KalmanParameters KalmanFilter::update(float iBias, int iTimeStep, const KalmanPa
231231

232232
// Compute Kt
233233
for(int i = 0; i < mDim; i++) {
234-
k[i] = P[dindex][i] / (P[dindex][dindex] + mV);
234+
k[i] = P[dindex][i] / (P[dindex][dindex] + mV*mV);
235235
}
236236
// Compute Pt|t
237237
for(int i = 0; i < mDim; i++) {

0 commit comments

Comments
 (0)