A Kalman filter sounds hard, but its main idea fits in one line: blend what you predicted with what you measured, trusting each by how good it is.
Key idea
Keep an estimate $x$ and its uncertainty (variance) $P$. A measurement $z$ has variance $R$. The gain is $K = \dfrac{P}{P + R}$. Update: $x \leftarrow x + K(z - x)$ and $P \leftarrow (1 - K)P$. Between measurements, predict the motion and let $P$ grow a little.
Why it works
If the prediction is shaky ($P$ big), $K$ is near 1 and the estimate jumps to the measurement. If the sensor is noisy ($R$ big), $K$ is near 0 and the estimate barely moves. The new $P$ is smaller than either: two pieces of evidence beat one. This is Bayes' rule for bell-shaped uncertainty.
Worked example: One update
Predict $x = 100$, $P = 4$. Measure $z = 106$, $R = 12$.
- $K = 4/16 = 0.25$.
- $x = 100 + 0.25 \times 6 = 101.5$.
- $P = 0.75 \times 4 = 3$.
Answer: Estimate 101.5, variance 3.
Common mistake
Thinking a Kalman filter just averages. It weighs each source by how much it is trusted, and the weights change as it runs.