New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here


by: Orval Funk


Marketplace > University of Pennsylvania > Statistics > STAT512 > MATHEMATICALSTATISTICS
Orval Funk
GPA 3.53


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in Statistics

This 12 page Class Notes was uploaded by Orval Funk on Monday September 28, 2015. The Class Notes belongs to STAT512 at University of Pennsylvania taught by Staff in Fall. Since its upload, it has received 11 views. For similar materials see /class/215440/stat512-university-of-pennsylvania in Statistics at University of Pennsylvania.

Similar to STAT512 at Penn




Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/28/15
Statistics 512 Notes 9 The Monte Carlo Method Continued The Monte Carlo method Consider a function g of a random vector X where X has density f Consider the expected value of g Eg I g1f d Suppose we take an iid random samples XV 7 Km from the density fCX Then by the law of large numbers m X P 1 gtEg The Monte Carlo method is to do a simulation to draw Klan7X from the density f and estimate Egl A Xi by Egf In a simulation we can make m as large as we want Standard error of the estimate is m 2 leg1m SEA gar 1 m By the Central Limit Theorem an approximate 95 con dence interval for Egl is Eg i1965 09 Example Monte Carlo estimation of 7r De ne the unit square as a square centered at 0505 with sides of length l and the unit circle as the circle centered at the origin with a radius of length l The ratio of the area of the unit circle that lies in the rst quadrant to the area of the unit square is 71 4 Let U1 and U2 be iid uniform 01 random variables Let gU17U2l if UlaUZ is in the unit circle and 0 7 otherwise Then EgU1gtU2 Z Monte Carlo method Repeat the experiment of drawing X U17U2 U1 and U2 iid uniform 01 random variables m times and estimate 7T by A Ef gw iz 77 4 m An approximate 95 con dence interval for 7Zis 2 m aUz39 ZzlgUleU12Zlnllz A 7Z39l96 4 m 1 Because 8U17U20 or 1 l is equivalent to il964 1 m In R the command runifn draws n iid uniform O 1 random variables Here is a function for estimating pi piestfunctionm Obtains the estimate of pi and its standard error for the simulation discussed in Example 581 n is the number of simulations Draw ul u2 iid uniform 01 random variables u1runifm u2runifm cntrep0m chkVector which checks if u1u2 is in the unit circle chku1A2u2A21 cnti1 if u1u2 is in unit circle cntchklt01 Estimate of pi est4meancnt Lower and upper con dence interval endpoints lciest 4meancntlmeancntmquot5 uciest4meancntlmeancntm 5 listestimateestlcilciuciuci gt piest100000 estimate 1 313912 lci 1 3133922 uci 1 3144318 Back to Example 585 The true size of the 005 nominal size ttest for random samples of size 20 contaminated normal distribution A We want to estimate EIlx1x20 gt 1 729 Monte Carlo method Zlltxi1 x120 gt 1729 m EIlx1x20 gt1729 where XI1 X220 is a random sample of size 20 from the contaminated normal distribution A Here X X1gtgtX20 and fis the density ofa random sample of size 20 from the contaminated normal distribution A and g ZX17 397X20gt1 729 How to draw a random observation from the contaminated normal distribution A 1 Draw a Bernoulli random variable B with p025 2 If BO draw a random observation from the standard normal distribution If Bl draw a random observation from the normal distribution with mean 0 and standard deviation 25 In R the command mormnmean0sdl draws a random sample of size n from the normal distribution with the speci ed mean and SD The command rbinomnsizelp draws a random sample of size n from Bernoulli distribution with probability of success p R function for obtaining Monte Carlo estimate EIlx1x20 gt 1 729 empalphacnfunctionnsims Obtains the empirical level of the test discussed in Example 585 nsims is the number of simulations sigmac25 SD when observation is contaminated probcont25 Probability of contamination alpha05 Signi cance level for ttest n20 Sample size tcqtlalphanl Critical value for ttest ic0 ic will count the number of times ttest is rejected fori in lnsims Bernoulli random variable which determines whether each observation in sample is from standard normal or normal with SD sigmac brbinomnsizelprobprobcont Sample observations from standard normal when b0 and normal with SD sigmac when bl sampmormnmean0sdlb24 Calculate tstatistics for testing mu0 based on sample tstatmeansampvarsampquot5n 5 Check if we reject the null hypothesis for the ttest iftstatgttc icicl Estimated true signi cance level equals proportion of rejections empalpicnsims Standard error for estimate of true signi cance level sel 96empalpl empalpnsimsquot 5 lciempalpl 96se uciempalpl 96se listempiricalalphaempalplcilciuciuci gt empalphacnlOOOOO empiricalalpha 1 004086 lci 1 003845507 uci 1 004326493 Based on these results the nominal 005 size ttest appears to be slightly conservative when a sample of size 20 is drawn from this contaminated normal distribution Generating random observations with given cdf F Theorem 581 Suppose the random variable U has a uniform O 1 distribution Let F be the cdf of a random variable that is strictly increasing on some interval 1 where FO to the left of I and F1 to the right of I Then the random variable X I F71U has cdf F where F 101eft endpoint of I and F 711 right endpoint of 1 Proof A uniform distribution on O 1 has the CDF FU u u for u E 071 Using the fact that the CDF F is a strictly monotone increasing function on the interval 1 then on PX g x PF 1U g x PFF U Fx PU g F x Fx Dif cult to use this method when simulating random variables whose inverse CDF cannot be obtained in closed form Other methods for simulating a random variable 1 AcceptReject Algorithm Chapter 581 2 Markov chain Monte Carlo Methods Chapter 114 R commands for generating random variables runif uniform random variables rbinom binomial random variables rnorrn normal random variables rt t random variables rpois Poisson random variables reXp exponential random variables rgamma gamma random variables rbeta beta random variables rcauchy Cauchy random variables rchisq chisquared random variables rF F random variables rgeom geometric random variables rnbinom negative binomial random variables Bootstrap Procedures Bootstrap standard errors X1Xniid with CDF F and variance 0392 2 Var M izVarXlXna n n n i J s We estimate SD00 by SEX Ewhere S is the 500 2 sample standard deviation What about SDiMedianXp Xn This SD depends in a complicated way on the distribution F of the X s How to approximate it Real World FgtX1 Xn 3T MedianX1gt39 gtXn The bootstrap principle is to approximate the real world by assuming that F I anhere F is the empirical CDF ie l the distribution that puts Z probability on each of X1Xn We simulate from F by drawing one point at random from the original data set Bootstrap World 13 3 XfX 3 7 MedianXfX The bootstrap estimate of SDMedianX1 Xn is SDiMedianX7 X where Xgtquot39gtX are iid draws from n How to approximate SDMedicmX 1 7 7 X The Monte Carlo method 1 m 1 m 2 E2i1gAXiZilgXij iZ ngfiZf ngfojzi EgX2 Eg2 Va goo Bootstrap Standard Error Estimation for Statistic Tn gX1Xn 1 Draw Xgtquot397X 2 Compute T gX1X 3 Repeat steps 1 and 2 m times to get Egan774 l m 1 m 2 4 Let seboot 2 Zr1Tm The bootstrap involves two approximations not so small approx error small approx error SDF z z sebool R function for bootstrap estimate of SEMedian bootstrapmedianfuncfunctionXbootreps medianXmedianX vector that will store the bootstrapped medians bootmediansrep0bootreps fori in lbootreps Draw a sample of size n from X with replacement and calculate median of sample XstarsampleXsizelengthXreplaceTRUE bootmediansimedianXstar sebootvarbootmediansquot 5 listmedianXmedianXsebootseboot Example In a study of the natural variability of rainfall the rainfall of summer storms was measured by a network of rain gauges in southern Illinois for the year 1960 gtrainfallc02010521003450010121307010 1001003043219181200111240026708003 022901003422700100104011720011429 0020405060811307002 gt medianrainfall 1 0045 gt bootstrapmedianfunc rainfall 10000 medianX 110045 seboot 1 002167736


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Janice Dongeun University of Washington

"I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.