function bias = cmpt_ml_var_bias(N_MC) % CMPT_ML_VAR_BIAS - studies the bias in the MaxLikelihood estimate of the variance % % Input: % N_MC: the number of monte carlo estimates to do of the following procedure % % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- % generate N_SAMPS ramdom samples: N_SAMPS=10; data = randn(N_SAMPS,N_MC); %mu = mean(data); %sigma_hat_sq = mean( ( data - repmat(mu,N_SAMPS,1) ).^2 ); sigma_hat_sq = var(data,1); % <- computed using a biased estimator %sigma_hat_sq = var(data); % <- computed using an unbiased estimator % take the mean of all of these samples (and compute the bias): bias = mean(sigma_hat_sq) - 1;