clc

seed = 7;
disp(['setting seed ',num2str(seed)])
rng(seed)

n=10000;
dim = 20;
disp(['dimension ',num2str(dim),', n is ',num2str(n)])
exV = exactVol(dim);
disp(['exact is ',num2str( exV ), ...
    ' fraction of cube ',num2str(exV/2^dim)])

[estV,estScaled] = sphereVolMC(dim,n)

disp(['est of area (or volume) ',num2str(estV)])
disp(['fraction of cube ',num2str(estScaled)])

% do the calculation m times and check mean/variance
mm=10;
disp(['repeat ',num2str(mm),' times'])
estMean  = 0;
estMean2 = 0;
for i=1:mm
    [estV,estScaled] = sphereVolMC(dim,n);
    estV   % no ; here so this value gets printed
    estMean = estMean + estV;
    estMean2 = estMean2 + estV*estV;
end
estMean  = estMean  / mm;
estMean2 = estMean2 / mm;
stdDev = sqrt( estMean2 - estMean*estMean );
disp(['mean ',num2str(estMean),' std dev ',num2str(stdDev)])