# Script to simulate 24 basketball games # of a Lady Griz player games <- 24 freethrow <- .72; twopoint <- .45; threepoint <- .34 attempt1 <- 8; attempt2 <- 15; attempt3 <- 7 points <- 0 totpoints <- c() # this makes room in R for a vector totpoints for(i in 1:games) { point1 <- rbinom(1, size=1, prob=freethrow) point2 <- rbinom(1, size=1, prob=twopoint) point3 <- rbinom(1, size=1, prob=threepoint) totpoints[i] <- point1*attempt1 + 2*point2*attempt2 + 3*point3*attempt3 } totpoints print("points per game is") sum(totpoints)/games # another way to express result cat("average points per game =", mean(totpoints),"\n")