Wednesday, July 8, 2009

PIE SIMULATION (SAS)

*PIE SIMULATION;
%Let Iter=10000000000000000;
data Simulation (keep=x y In_Out Check);
format In_Out $3.;
seedx = 4002512;
seedy = 21548714;
do i = 1 to &Iter.;
x=ranuni(seedx); y=ranuni(seedy);
Check=x*x + y*y - (x+y) +0.25;
if Check <= 0 then In_Out="In";
else In_Out="Out";
output;
end;
run;
proc freq noprint data=Simulation; table In_Out/NoCol NoRow out = Freq; run;
data _null_;
set freq;
if In_Out="In" then call symput ("Q", Count);
run;
proc datasets nolist; delete Freq Simulation; run; quit;
%let Pie=%sysevalf(4*&Q./&Iter.);
%put &Pie.;

No comments:

Post a Comment