I am trying to make sense of the below code. I am taking a large sample so that I get good estimates for standard deviation.
N = 25;
h1 = ones(1, N)./N;
L = 1000000;
s = ones(1, L);
n = 0.1*randn(1, L);
x = s + n;
stdx = std(x);
y = filter(h1,1,x);
stdy = std(y);
This code will give me stdx = 0.1
and stdy = 0.02
, which is expected since $\sigma_y=\sigma_x/{\sqrt{N}}$as we are essentially doing an average filter.
But giving more amplitude to the signal s = 10*ones(1, L);
and running the same code above is giving me a stdy = 0.0344
. Shouldn't the standard deviation be same in both the cases since the signal s
has no variance?