############################################### ## Author: Joshua M. Tebbs ## Date: 20 July 2025 ## Update: 27 July 2025 ## STAT 509 course notes: R Code Chapter 2 ############################################### # Figure 2.1 # Page 6 bottles = rbinom(1000,1,0.11) # Create plot of the proportion of defective bottles # Initialize prop.def = bottles*0 for (i in 1:1000){ prop.def[i] = sum(bottles[1:i])/i } plot(prop.def,ylab="Proportion of defective bottles",xlab="Number of bottles tested",type="o",pch=16) abline(h=0.11,lty=2)