%
%  math495/stat490 -- 06 nov 03 -- djm
%
%  w10ehr.m:  

clear

%  test parameters
Nexpt = 1000;  Nitems = 4;

%  initialize random number generator
phone = 2914814;
rand('state',phone);  %  initialize with my office phone number

%  data
data = zeros(Nexpt,1);

%  run ehrenfest experiments
for kk=1:Nexpt
    items = 0;  moves = 0;
    while (items~=Nitems)
        items = items - 1 + 2*(rand(1,1)>items/Nitems);
        moves = moves + 1;
    end
    data(kk) = moves;
end

hist(data)
mean(data)