% Script to compute area of disk by Monte Carlo
% Choose (x,y) uniformly in [0,1]^2
% Count how many lie in disk x^2 + y^2 < 1
% Plot points

% N is number of points
tic;
N = 1000;
count=0;
figure; hold on; grid on;
title('Computing area of disk by Monte Carlo Method');
for k=1:N
x=rand;
y=rand;
r=x^2+y^2;
if r < 1
count=count+1;
scatter(x,y,'r','.');
else
scatter(x,y,'b','.');
end % if
end % for k
area = 4*count/N
toc
return