1 / 8

Lecture 4

Lecture 4. Runs. Q: Toss a coin 1000000 times. Run is an unbroken sequence of H in a row What is the length of the longest run Take guesses (closest will get a cookie) We will write an R code togather. Issues. Case sensitive dog and Dog are different Careful of extra spaces Brackets

travis
Download Presentation

Lecture 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 4

  2. Runs • Q: • Toss a coin 1000000 times. • Run is an unbroken sequence of H in a row • What is the length of the longest run • Take guesses (closest will get a cookie) • We will write an R code togather

  3. Issues • Case sensitive dog and Dog are different • Careful of extra spaces • Brackets • ( ) • arguments of functions sum(coin); for(i in 1:10), if(coin<1) • grouping math formulas (1+3)*(4+5) • [ ] indexing valus in a list coin[10] • { } grouping commands togather

  4. Are we smarter than chimps? • In each of the following pair one country has twice the child mortality rate than the other. • Malaysia or Russia • Poland or South Korea • Pakistan or Vietnam • Thailand or South Africa • Sri Lanka or Turkey

  5. Answers • In each of the following pair one country has twice the child mortality rate than the other. • Malaysia or Russia • Poland or South Korea • Pakistan or Vietnam • Thailand or South Africa • Sri Lanka or Turkey • Collect data and draw a histogram

  6. Chimps histogram plot(0:5,20*dbinom(0:5,5,.5),type="h",xlab="number of correct answers",ylab="average number of chimps")

  7. What about uncertainty • 1000 classes of chimps simulated. • Classes ordered based on average performance • Will Show: Worst class, 2.5%, 5%, 25% nclass=1000 nchimps=20 nquestions=5 count1=matrix(0,nrow=nclass,ncol=nquestions+1) m1=rep(0,nclass) for (i in 1:nclass){ data1=rbinom(nchimps,nquestions,.5) count1[i,]=tabulate(data1,nquestions+1) m1[i]=mean(data1) } i1=order(m1) i2=order(count1[,1]) par(mfrow=c(2,2)) plot(0:5,count1[i1[1],],type="h",xlab="number of correct answers",ylab="average number of chimps",sub="1:1000") plot(0:5,count1[i1[25],],type="h",xlab="number of correct answers",ylab="average number of chimps",sub="25:1000") plot(0:5,count1[i1[50],],type="h",xlab="number of correct answers",ylab="average number of chimps",sub="50:1000") plot(0:5,count1[i1[250],],type="h",xlab="number of correct answers",ylab="average number of chimps",sub="250:1000")

  8. Chimps histogram

More Related