Homework2 - Homework 2 36-325/725 due Friday Sept 7 Hint Define etc Next show are disjoint(ii and(iii for that(i the every Also it will help to

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Homework 2 36-325/725 due Friday Sept 7 Hint: Define , , , etc. Next show are disjoint, (ii) and (iii) for that (i) the every . Also, it will help to recall the definition of an infinite sum: . and (3) Chapter 1.13 Problem # 1 Suppose that a fair coin is tossed repeatedly until both a head and tail have appeared at least once. (a) Describe the sample space . (b) What is the probability that three tosses will be required? is independent of itself then (5) Suppose a coin has probability of falling heads. If we flip the coin many times, we would expect the proportion of heads to be near . We will make this formal later. Let's explore the idea now using R (or Splus). Let's pick a value of and generate coin flips: p <- .3 n <- 1000 1 e ( d (4a) Show that if event. (4b) Show that if or then is independent of every other is either 0 or 1. @ 9 @ (2) Chapter 1.11 Problem # 1 Suppose that and are independent events. Show that pendent events. 0W% U V Q&% T % 9 # '&6% 0R% '&% % 9 Q&% P% '&% 0 ! D 6 D # B @ B ! E@ BCA 0 A9 ! A CA# @ 7 6 0 ( ( 6 8 # 54321 $)% b 0 c$( 8 e Y (1) Chapter 1.10 Problem # 11. Let be an infinite sequence of events such that Show that ! 0 9 0 9 '&% # ! $" ` 0 aE( 8 9 S . 7 % X '&6% T # 6 34521 U S H F6 IG9 are inde- e ### generate n coin flips each having prob p x <- rbinom(n,1,p) p.empirical <- cumsum(x)/(1:n) ### cumsum computes the cumulative sum ### if you don't see wha this is doing, ### try it for n=5 and look carefully par(mfrow=c(2,2)) ### put 4 plots per page plot(1:n,p.empirical,type='l', xlab='number of coin flips', ylab='',ylim=c(0,1)) lines(1:n,rep(p,n),lty=3,col=2,lwd=3) ### add the true value of p (6) Here is a related experiment. Suppose we flip a coin times. Let be the number of heads. We call a binomial random variable. We will discuss this in class in detail. To simulate a value of : k <- 10 p <- .3 flips <- rbinom(k,1,p) print(flips) X <- sum(flips) print(X) ### k single flips X <- rbinom(1,k,p) Intuition suggests that will be close to . To see if this is true, we can repeat this experiment many times and average the values. Here is one way to do the simulation: nsim <- 1000 output <- rep(0,nsim) for(i in 1:nsim){ output[i] <- rbinom(1,k,p) } print(mean(output)) print(k*p) 2 g e Pf g Alternatively, we can simulate directly as follows: ### sum of k flips g f e g S Experiment with different values of your R code. and . Hand in a few plots. Do not hand in g g Here is a better way to do the same thing: nsim <- 1000 output <- rbinom(nsim,k,p) hist(output) ### draw a histogram of the output plot(table(output)) ### another way to plot it print(mean(output)) print(k*p) 3 e Cf g Try this a few times. How close is histogram. (on average) to ? Hand in your ...
View Full Document

This note was uploaded on 05/25/2008 for the course STAT 36625 taught by Professor Larrywasserman during the Fall '01 term at Carnegie Mellon.

Ask a homework question - tutors are online