@bencevans/kalman-filter
Version:
50 lines • 1.55 kB
JavaScript
;
exports.__esModule = true;
var test = require("tape");
var _1 = require(".");
test("single run", function (t) {
var filter = new _1["default"]({
initialEstimate: 0,
initialErrorInEstimate: 1
});
var _a = filter.update({
measurement: 20,
errorInMeasurement: 0
}), estimate = _a[0], errorInEstimate = _a[1];
t.equal(estimate, 20);
t.equal(errorInEstimate, 0);
t.end();
});
test("multi run", function (t) {
var _a, _b, _c;
var filter = new _1["default"]({
initialEstimate: 68,
initialErrorInEstimate: 2
});
var _d = filter.update({
measurement: 75,
errorInMeasurement: 4
}), estimate = _d[0], errorInEstimate = _d[1];
t.equal(estimate.toFixed(2), "70.33");
t.equal(errorInEstimate.toFixed(2), "1.33");
_a = filter.update({
measurement: 71,
errorInMeasurement: 4
}), estimate = _a[0], errorInEstimate = _a[1];
t.equal(estimate.toFixed(2), "70.50");
t.equal(errorInEstimate.toFixed(2), "1.00");
_b = filter.update({
measurement: 70,
errorInMeasurement: 4
}), estimate = _b[0], errorInEstimate = _b[1];
t.equal(estimate.toFixed(2), "70.40");
t.equal(errorInEstimate.toFixed(2), "0.80");
_c = filter.update({
measurement: 74,
errorInMeasurement: 4
}), estimate = _c[0], errorInEstimate = _c[1];
t.equal(estimate.toFixed(2), "71.00");
t.equal(errorInEstimate.toFixed(2), "0.67");
t.end();
});
//# sourceMappingURL=test.js.map