% Compare statistical convergence of various measurements of group size.
clear
Ngroup = 5 % 5-shot groups
Ndim = 2; % 2D targets!
Ntrials = 10000 % Number of trials (groups).

% Initialize sums
rmsrad_sum = 0;
extspr_sum = 0;

for trial = 1:Ntrials
   r = randn(Ngroup, Ndim);
   
   % RMS radius
   rmsrad(trial) = rms_radius(r);
   rmsrad_sum = rmsrad_sum + rmsrad(trial);
   rmsrad_avg(trial) = rmsrad_sum/trial; 
   
   % Extreme spread
   extspr(trial) = extreme_spread(r);
   extspr_sum = extspr_sum + extspr(trial);
   extspr_avg(trial) = extspr_sum/trial;
end

% Measure the convergence of each method

rmsrad_fractional_uncertainty = std(rmsrad)/rmsrad_avg(Ntrials)
extspr_fractional_uncertainty = std(extspr)/extspr_avg(Ntrials)
