DOC PREVIEW
MIAMI IES 612 - Study Notes

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

/*MC-handout-08apr03.doc*/options ls=75 nocenter nodate;data auc;title Monte Carlo Simulation 1: integration using random numbers;title2 Estimating PI = 3.14159;* circle equation x^2 + y^2 = 1;do j=1 to 5000; x=ranuni(0); * generate x and y uniform over the int. [0,1]; y=ranuni(0); ilt = 0; clt = "."; if (y le sqrt(1-x*x)) then do; ilt=1; clt = "+"; end; output;end;proc plot data=auc; plot y*x=clt;proc means data=auc; var ilt; output out=nmean mean=piover4; run;data junk; set nmean; piest = 4*piover4; se_piest = 4*sqrt(piover4*(1-piover4)/5000); B_pi = 2*se_piest; put “Estimated pi = “ piest; * writes to the sas log page; put “SE(Est. pi) = “ se_piest; put “Bound (est. pi) = “ B_pi;run;proc print data=junk; run;Monte Carlo Simulation 1: integration using random numbers Estimating PI = 3.14159 Plot of y*x. Symbol is value of clt. y ‚ ‚1.0 ˆ + ++++ +.+.. ........ . .... . .. ......... . .. ......... .. ‚ +++ ++++++++++..++............. .. .... ............... ....... . ‚ + +++++++ ++ ++++++++... ......... ... . ..... ............ ...... ‚ ++++ +++++++++++++ + ++++..................... .. ............. ‚ +++++++ ++++ +++++++++++++++++.. .. ...... .... ....... .......... ‚ ++++++++++ +++++++++++++++++ ++++. .... .................. ..... ‚ ++++++ + ++ ++++++ ++++++++++++++++.+................. ..........0.8 ˆ +++++ ++++++++ ++++ ++++ +++ ++++++++ ........................ ‚ ++ +++ ++++++++++++++++++++++++ +++++++++ ........... ........... ‚ +++++++++ +++++++ ++++++++ +++++ ++++++ ++..... .. ..... . ..... ‚ ++++++++ ++++++++++++++++++++ +++++++ +++++++. ... .............. ‚ +++++++ +++++++++ +++++++++ + ++++ ++ ++++++++++ . ............. ‚ ++++++++ +++++++++++ +++++++++++++++++ +++++++++++........... .... ‚ + +++++++++++++ ++++++ +++ +++++ +++++++ +++++++ ....... .....0.6 ˆ ++++++++++ + ++++++ +++++++ ++++ + + +++++++++++ ++....... .. . . ‚ +++++++++++++++++++++++++++++++ + +++++++ +++++++ +++.... . .... ‚ ++++++ ++ ++++++++++++++++++++++++++++ ++ +++++++ +++.... ...... ‚ +++++++ + +++++ +++++++++ ++++++++++++++++++ ++++++++ + ........ ‚ ++++++++++++++++++++++ + ++++++++ +++ +++ + ++++ + +++.+........ ‚ +++++++++ +++++++++++++ +++++++ + ++++++++++++ ++++++++++++..... . ‚ +++++ +++++++++++++ +++++++++ +++++++++ +++++++++ ++++++++......0.4 ˆ +++++++++++++++ +++ ++++ +++++++ ++++++++++++++++++ +++++++ ..... ‚ ++++ +++ +++++++++++++++++++++++++++ ++++ ++++++++++++++++++... ‚ +++++++++++++++++++++ +++++ +++++ +++ ++++++++++++++ +++++++++.... ‚ ++++++++++++++++++++++++++++ ++++++++++++ ++++++++++++ ++ +++ .... ‚ ++++++++ +++ ++++++++++++++++++++++ ++++++++++++++++ +++ + ++ +... ‚ +++++++++++++++ ++++++++++++++ ++ ++++++++ ++++++++ ++++++++++ ... ‚ ++++++++++++++++++++++ ++++ +++ +++++++++++++++++++ ++ ++ ++++++..0.2 ˆ +++++++++++++++++++++++ + + ++++++++++ +++++++++++++++++++++++ ‚ ++++ +++ +++ +++++++ + +++++++++++++++++++++++++++++++++ + + +++ ‚ ++++++++++++++++ ++++++++++++++++++ ++++++++++++++++++ ++++++++ ‚ ++++ + +++++++++++++++++++++++++ +++++++++++++ ++++ +++ ++++++. ‚ +++++++ ++++ +++++ ++++++++++++ ++++++ ++ ++++++ + ++++++++++++ ‚ +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. ‚ +++ +++++++++++++++++ +++++++++++ +++++ +++++++++ ++ ++++++ + + +0.0 ˆ + + ++ ++++++ + ++++++ + ++ ++ + + ++ ++ ++ +++ ++ ++++ ‚ Šƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒ 0.0 0.2 0.4 0.6 0.8 1.0 xNOTE: 2930 obs hidden.Monte Carlo Simulation 1: integration using random numbers Estimating PI = 3.14159The MEANS Procedure Analysis Variable : ilt N Mean Std Dev Minimum Maximumƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ5000 0.7834000 0.4119689 0 1.0000000ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒMonte Carlo Simulation 1: integration using random numbers Estimating PI = 3.14159Obs _TYPE_ _FREQ_ piover4 piest se_piest B_pi 1 0 5000 0.7834 3.1336 0.023302 0.046604 [PROC PRINT output]data monte2;title Monte Carlo Simulation 2: #boys & girls in families of size 4;array x x1-x4; * array containing family of 4 kids;do j=1 to 1000; * generate 1000 familes; numboys = 0; * initialize counters of #boys and #girls; numgirls=0; do over x; * generate a family of 4 kids; p = ranuni(0); if p<.5 then do; numboys = numboys + 1; x = 0; end; else do; numgirls = numgirls + 1; x = 1; end; end; * end of the loop for KIDS; outcome = 0; if numboys=numgirls then outcome=1; drop j p; output;end; * end of the loop for FAMILIES;proc print;proc freq; table outcome numboys*numgirls; run;Monte Carlo Simulation 2: #boys & girls in families of size 4 Obs x1 x2 x3 x4 numboys numgirls outcome 1 1 0 0 0 3 1 0 2 0 0 0 1 3 1 0 3 0 0 0 1 3 1 0 4 0 0 1 1 2 2 1 5 0 1 0 1 2 2 1 6 1 1 0 1 1 3 0 7 1 0 0 1 2 2 1 8 1 1 1 1 0 4 0 9 1 0 1 0 2 2 1 10 0 0 0 0 4 0 0 11 0 0 0 1 3 1 0. . . 990 0 0 1 0 3 1 0 991 1 1 1 0 1 3 0 992 0 0 1 1 2 2 1 993 1 1 1 0 1 3 0 994 1 0 1 0 2 2 1 995 1 1 0 0 2


View Full Document

MIAMI IES 612 - Study Notes

Download Study Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?