Skip to content

Commit

Permalink
feat: polymorphism on covariance
Browse files Browse the repository at this point in the history
  • Loading branch information
piercus committed May 25, 2023
1 parent 5377359 commit 66ce358
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kalman-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class KalmanFilter extends CoreKalmanFilter {
* @param {Number} [tolerance=1e-6] returns when the last values differences are less than tolerance
* @return {Array.<Array.<Number>>} covariance
*/
asymptoticStateCovariance({limitIterations = 1e2, tolerance = 1e-6}={}) {
asymptoticStateCovariance({limitIterations = 1e2, tolerance = 1e-6} = {}) {
let previousCorrected = super.getInitState();
let predicted;
const results = [];
Expand Down
5 changes: 5 additions & 0 deletions lib/setup/extend-dynamic-init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const {diag} = require('simple-linalg');
const polymorphMatrix = require('../utils/polymorph-matrix.js');

/**
*Initializes the dynamic.init when not given
Expand Down Expand Up @@ -30,5 +31,9 @@ module.exports = function ({observation, dynamic}) {
throw (new Error('dynamic.init should have a mean key'));
}

dynamic.init = Object.assign({}, dynamic.init, {
covariance: polymorphMatrix(dynamic.init.covariance, {dimension: dynamic.dimension}),
});

return {observation, dynamic};
};

0 comments on commit 66ce358

Please sign in to comment.