Kalman Filter Gain Explorer
Try Raise Process noise Q from 0.01 while keeping Measurement noise R at 0.1.
Observe The defaults yield a Q/R ratio of 0.1000, a final gain of 0.2702 and 27.0% measurement trust.
Explain Starting with covariance 1, each update adds Process noise Q, divides that prediction by itself plus Measurement noise R to get gain, then reduces covariance.
Calculate Kalman gain
Reset
Technical boundaries. This scalar calculation assumes constant Q and R and performs exactly twenty covariance updates. The value labelled steady-state gain is the last computed gain; no sensor readings or state estimates are filtered.
Try It: Kalman Filter Gain Explorer
Adjust Q (process noise) and R (measurement noise) to see how the Kalman gain converges. Higher Q/R ratio means the filter trusts measurements more; lower ratio means it trusts its own predictions more.
viewof kalmanQ = Inputs. range ([0.001 , 1.0 ], {
value : 0.01 ,
step : 0.001 ,
label : "Process noise Q"
})
viewof kalmanR = Inputs. range ([0.01 , 5.0 ], {
value : 0.1 ,
step : 0.01 ,
label : "Measurement noise R"
})
kalmanSteps = {
let steps = [];
let p = 1.0 ; // Initial estimation error
for (let i = 0 ; i < 20 ; i++ ) {
p = p + kalmanQ; // Prediction
let k = p / (p + kalmanR); // Update gain
p = (1 - k) * p; // Update covariance
steps. push ({step : i + 1 , gain : k, covariance : p});
}
return steps;
}
steadyStateGain = kalmanSteps[kalmanSteps. length - 1 ]. gain
trustPercent = (steadyStateGain * 100 )
html `<div style="background: var(--bs-light, #f8f9fa); padding: 20px; border-radius: 8px; border-left: 4px solid #9B59B6; margin-top: 15px; font-family: Arial, sans-serif;">
<h4 style="color: #2C3E50; margin-top: 0;">Kalman Gain Convergence</h4>
<table style="width: 100%; border-collapse: collapse; margin-top: 10px;">
<tr style="background: #f3ecf8;">
<td style="padding: 10px; border-bottom: 1px solid #e2d5ed; font-weight: bold; color: #2C3E50;">Q/R Ratio</td>
<td style="padding: 10px; border-bottom: 1px solid #e2d5ed; color: #2C3E50;"> ${ (kalmanQ / kalmanR). toFixed (4 )} </td>
</tr>
<tr>
<td style="padding: 10px; border-bottom: 1px solid #eee; font-weight: bold; color: #2C3E50;">Steady-State Gain (K)</td>
<td style="padding: 10px; border-bottom: 1px solid #eee; color: #9B59B6; font-weight: bold;"> ${ steadyStateGain. toFixed (4 )} </td>
</tr>
<tr style="background: #f3ecf8;">
<td style="padding: 10px; border-bottom: 1px solid #e2d5ed; font-weight: bold; color: #2C3E50;">Measurement Trust</td>
<td style="padding: 10px; border-bottom: 1px solid #e2d5ed; color: #9B59B6; font-weight: bold;"> ${ trustPercent. toFixed (1 )} % measurement, ${ (100 - trustPercent). toFixed (1 )} % prediction</td>
</tr>
<tr>
<td style="padding: 10px; font-weight: bold; color: #2C3E50;">Interpretation</td>
<td style="padding: 10px; color: #2C3E50;"> ${ steadyStateGain > 0.5 ? "Filter favors measurements (responsive but noisier)" : steadyStateGain > 0.2 ? "Balanced between measurements and predictions" : "Filter favors predictions (smooth but slower to respond)" } </td>
</tr>
</table>
<p style="margin-top: 15px; color: #555; font-size: 13px; font-style: italic;">
Gain K converges after ~5-10 steps. K near 1.0 = follows raw data closely. K near 0.0 = heavy smoothing, ignores measurements. Try Q=0.001, R=1.0 for heavy smoothing; Q=0.5, R=0.1 for responsive tracking.
</p>
</div>`
Back to the chapter