sta4321-1

# sta4321-1 - n&amp;amp;lt;-200 x1&amp;amp;lt;-round(runif(n))

This preview shows pages 1–3. Sign up to view the full content.

Simulating Random Variables

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Simulating Coin Flips Probability of a head Let 0 represent heads and 1 represent tails. > round(runif(10)) [1] 1 1 0 0 0 0 0 0 1 0 > mean(round(runif(10))) [1] 0.5 > mean(round(runif(1000))) [1] 0.486 > mean(round(runif(10^6))) [1] 0.499662 Arthur Berg Simulating Random Variables 2/ 3
Simulating Coin Flips Simulation Paths Now we keep track of the proportion of heads as we increase the sample size
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n&lt;-200 x1&lt;-round(runif(n)) x2&lt;-round(runif(n)) x3&lt;-round(runif(n)) plot(cumsum(x1)/(1:n), type=&quot;l&quot;, col=&quot;red&quot;, ylim=c(0,1), lwd=3) lines(cumsum(x2)/(1:n), type=&quot;l&quot;, col=&quot;blue&quot;, lwd=3) lines(cumsum(x3)/(1:n), type=&quot;l&quot;, col=&quot;orange&quot;, lwd=3) Arthur Berg Simulating Random Variables 3/ 3...
View Full Document

## This note was uploaded on 10/04/2011 for the course STA 4321 taught by Professor Staff during the Fall '08 term at University of Florida.

### Page1 / 3

sta4321-1 - n&amp;amp;lt;-200 x1&amp;amp;lt;-round(runif(n))

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online