%
%  macm 202 -- 31 mar 03 -- djm
%
%  w13random.m:  stats for purely random decks

Ncards = 52;  Ndeals = 800;

perfect = (1:Ncards)';

%  array for variance data

data = zeros(1,Ndeals);

for k=1:Ndeals
    
%  completely random deal
    deck = rand(1,Ncards)';
    [junk deck] = sort(deck);
    
    data(1,k) = sum((deck-perfect).^2)/Ncards;
end

%  plot the EDF of the variance data

ord_data = sort(data(1,:));
Fplus = (1:Ndeals)/Ndeals;  Fminus = (0:Ndeals-1)/Ndeals;
edfx = [ord_data ; ord_data];  edfy = [Fminus ; Fplus];

figure(1);  clf
plot(edfx(:),edfy(:),'r')
title('\bf EDF of variances')
xlabel('\bf ordered variances')
ylabel('\bf empirical distribution function')
axis([0 ord_data(end) 0 1]);

data_mean = mean(data)
data_var = var(data)

