Help? I set an exam question with 10 boxes to be filled from 13 possible answers. If randomly completed, what should be the average mark?

  • @KeithRMatthews, 12:13 PM - 15 Dec 2016
library(ggplot2)
answers <- letters[1:10]
options <- letters[1:13]

functions to give random answers and mark them

giveAnswers <- function(options) sample(options, size = 10, replace = FALSE)
markAnswers <- function(correct, given) sum(given == correct)

collect scores

scores <- numeric(1e5L)
for(i in seq_along(scores)) {
  scores[i] <- markAnswers(answers, giveAnswers(options))
}

averages

mean(scores)
## [1] 0.766
median(scores)
## [1] 1

plot

ggplot(data.frame(score = scores), aes(x = scores)) +
  geom_bar(stat = "count")

plot of chunk unnamed-chunk-5