Let
$$B = \begin{pmatrix} 1/3 & 1/3 & 0 & 0 & 0 & \dots & 0 & 0 \\ 1/3 & 1/3 & 1/3 & 0 & 0 & \dots & 0 & 0 \\ 0 & 1/3 & 1/3 & 1/3 & 0 & \dots & 0 & 0 \\ 0 & 0 & 1/3 & 1/3 & 1/3 & \dots & & . \\ 0 & 0 & 0 & 1/3 & 1/3 & \dots & & . \\ \vdots & \vdots & \vdots & \vdots & \vdots & \dots & 0 & . \\ \vdots & \vdots & \vdots & \vdots & \vdots & \dots & 0 & 1/3 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1/3 & 1/3 \\ \end{pmatrix}$$
Let $f(x)$ be a function. I see that if I add random noise to f(x), $g(x)=f(x) + noise$. Then $Bg(x)$ is closer to $f(x)$ than $g(x)$.
Why is that? Can someone explain how this works?
I've tried to make a small example on Wolfram Alpha, but it doesn't really help.
Note that this matrix is averaging each element with its adjacent values so $Bg(x)$ is a smoothed version of $g(x)$. For $n(x)$ denoting the noise signal
$$ Bg(x)=Bf(x) + Bn(x) \simeq f(x)+0 $$
assuming your noise is zero mean and the original signal $f(x)$ is smooth enough (so $Bf(x)\simeq f(x)$, we get approximately the same signal after smoothing it).
If you want a simple example in Python: