I am trying to verify, through numerical simulation, the expression for the variance of the variance estimation, namely:
$$ \text{Var}(s^2) = \frac{2}{n \, \sigma^4} $$
where $n$ is the number of samples, and $\sigma$ is the standard deviation of the process (assumed Gaussian), but something is wrong. (For the source of this expression, see http://www.statlect.com/variance_estimation.htm/)
The numerical simulation is quite simple, as shown in the Matlab code below:
% number of Montecarlo runs
NMC = 10000;
% number of samples at each run
n = 100;
% true standard deviation of the random process
stdan = 0.1;
stdMC = [];
% Montecarlo simulation
for j=1:NMC
% generate n samples of the random process
% a white noise with stdan standard deviation and zero mean
y = stdan*randn(n, 1);
% estimate the standard deviation based on the n samples of this run.
std_i = std(y);
% store it
stdMC = cat(1, stdMC, std_i);
end
% compute the estimation error (difference between the estimated standard deviation at each run and the true one)
estd = stdMC - repmat(stdan, NMC, 1);
% compute the expected variance and standard deviation of the estimator
estd_var_an = (2/n)*stdan^4
estd_std_an = sqrt(estd_var_an)
% compute the actual estimated variance of the estimations
estd_var = var(estd)
estd_std = std(estd)
But it returns
estd_var_an =
2.0000e-06
estd_std_an =
0.0014
estd_var =
5.1535e-05
estd_std =
0.0072
Showing that the simulated variance estd_var
of the estimator is totally different (25 larger) than the true one estd_var_an
.
See also: Variance of sample variance?