m = 2.0; % slope sigmas = [0.1, 1.0]; % standard deviations ns = [100, 1000]; % number of data pairs trials = 1000; % number of data sets for i = 1:length(sigmas) sigma = sigmas(i); for j = 1:length(ns) n = ns(j); slopes = zeros(trials, 1); for k=1:trials % data pairs: x = 5.0*rand(n, 1); y = m*x + sigma*randn(n, 1); % fit: slopes(k) = mleslope(x, y); end subplot(2, 2, 2*(i-1)+j); bins = [1.9:0.005:2.1]; hist(slopes, bins); xlabel('estimated slope'); title(sprintf('sigma=%g, n=%d', sigma, n)); end end savefigpdf(gcf, 'mlepropest.pdf', 15, 10);