probability4

onionnet

typed answers with explanation either in doc or in pdf. 

 

 strict due.  by midnight 10/01in MST

 

 for Q5, you will need to use R program http://www.r-project.org.

 I also need coding (detail procedure you operate )of it.

 

you may use this for Q5.

 

# hmwk5_r.txt

# p is probability of heads
p=0.25;

for (n in 1:20) {

  # seq is used to record the flips
  seq=as.character();

  # flip until we get H
  count1<-0;
  got_head<-0;
  while (got_head==0) {
    count1<-count1+1;
    flip<-rbinom(1,1,p);
    if (flip==0) seq=paste(seq,"T");
    if (flip==1) seq=paste(seq,"H");
    if (flip==1) got_head<-1;
  }

  # now flip until we get T
  count2<-0;
  got_tail<-0;
  while (got_tail==0) {
    count2<-count2+1;
    flip<-rbinom(1,1,p);
    if (flip==0) seq=paste(seq,"T");
    if (flip==1) seq=paste(seq,"H");
    if (flip==0) got_tail<-1;
  }

  cat(sprintf("%s: X is %d+%d=%d \n",seq,count1,count2,count1+count2));
}

 

  • 13 years ago
  • 15
Answer(1)

Purchase the answer to view it

NOT RATED
  • prob4ans.doc
  • new.doc
Bids(1)