Blog of Andrés Aravena
CMB2:

Homework 8

31 May 2021. Deadline: Friday, 4 June, 9:00.

Please use this template for your answers.

What will be the score?

A group of students will take a multiple-choice exam with 140 questions. The students attended only to the first half of the course, so they have 80% probability of answering correctly each of the first 70 questions, and they have 10% probability of answering correctly each of the last 70 questions.

Notice that, given our limited knowledge of the student population, we assume that each question is a “coin”, with different probabilities depending on how much did the student pay attention to the class (and do the homework, and so on).

Simulate one exam

We want our code to be as general as possible. Thus, we will not fix the number of questions. Instead we will take the number of questions as an input, and assume that half of them are easy for the student (i.e. have 80% probability of being correct) and the other half are hard (that is, have 10% probability of being correct).

Please write a function, called num_correct_ans, that takes the number of questions as input nq, simulates the evaluations of all the answers (“correct” or “wrong”) in a single exam, and returns the total number of correct answers in one exam.

(Hint: The problem is much easier if you choose a good way to represent “correct” and “wrong”.)

If all is right, you should get the following results:

N <- 10000
sinav <- replicate(N, num_correct_ans(140))
barplot(table(sinav)/N)

Example result from simulation.

Score correction

The score of the exam is not directly the number of correct answers. Instead, the students get 1 point for each correct answer, and -0.25 for each wrong answer. Please write a function, called exam_score, that takes the number of questions as input, simulates all the questions in a single exam, and returns the score of the exam. (Hint: It is easy to modify the code from the previous answer to answer this question.)

If all is right, you should get the following results:

score <- replicate(N, exam_score(140))
barplot(table(score)/N)

plot of chunk unnamed-chunk-4

Average and standard deviation

What is the average score? What is the standard deviation of the score? Your numbers will not be the same as these ones, but they should be similar

[1] 52.507500  5.979085
# Write here

Confidence interval

Find an interval containing 95% of the resulting scores. You can assume that the population follows a Normal distribution.

[1] 40.78871 64.22629
# Write here

Why Normal?

In the previous question we assumed that the population follows a Normal distribution. Is this hypothesis justified? Why?

Answer here. Do not delete the block markers.

Deadline: Friday, 4 June, 9:00.

Originally published at https://anaraven.bitbucket.io/blog/2021/cmb2/homework-8.html