% MCAS Question 9, solved as a normal pdf
% MCASq9normal.m
% Solves question 9, 10th grade math, 2001 MCAS
% Written by E Gallagher 9/5/01
% Eugene.Gallagher@umb.edu
% Last revised 9/13/01
clf % clears the previous graph
hold on; % no graphs will be erased;
theta = 0:pi/50:2*pi;
% first draw a circle of radius 3, centered at 0
r=3;
x = r * cos(theta) + 0;
y = r * sin(theta) + 0;
plot(x, y);axis('square');
% Now draw a circle of radius 1, centered at 0
r=1;
x = r * cos(theta) + 0;
y = r * sin(theta) + 0;
plot(x, y);
% Now fill this circle with yellow;
h =fill(x,y,'y');
hold on
figure(gcf)
% Modify dart throwing code from Nahin's pisim.m
% trials=1e5
trials=1000
rand('state',100*sum(clock))  %set new seed for generator;
   x=(randn(trials,1))';         % generate a column of standard normal random numbers(mean 0, sd=1) for x
   y=(randn(trials,1))';         % generate a column of standard normal random numbers(mean 0, sd=1) for y
   r=sqrt(x.^2+y.^2);    % compute Euclidean distance from origin to randomly placed point dart (x,y);
   plot(x(r<3),y(r<3),'.r','MarkerSize',2);figure(gcf)
p_est=sum(r<=1)/sum(r<=3)