Blog of Andrés Aravena
CMB2:

# Homework 8

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

# 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) ## 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) ## 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

 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.

 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.90938604,"math_prob":0.909568,"size":2553,"snap":"2023-40-2023-50","text_gpt3_token_len":588,"char_repetition_ratio":0.13613182,"word_repetition_ratio":0.09692671,"special_character_ratio":0.24010968,"punctuation_ratio":0.118473895,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9988523,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-21T09:59:08Z\",\"WARC-Record-ID\":\"<urn:uuid:195f7f68-0d75-4b6e-85a9-afafedaa9a51>\",\"Content-Length\":\"9547\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9d167c66-2923-4470-bd1b-cae15eddb178>\",\"WARC-Concurrent-To\":\"<urn:uuid:fc795301-37a3-419b-93b8-c87f9d473126>\",\"WARC-IP-Address\":\"185.199.110.153\",\"WARC-Target-URI\":\"http://www.dry-lab.org/blog/2021/cmb2/homework-8.html\",\"WARC-Payload-Digest\":\"sha1:UYGO7PJ3K6HPQ6GEEZKXH2GOVYBZ22M4\",\"WARC-Block-Digest\":\"sha1:K56AFNKKGV6W3XJTT5ZUL2H7DFMZWFTK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233505362.29_warc_CC-MAIN-20230921073711-20230921103711-00148.warc.gz\"}"}