Created
November 28, 2018 10:50
-
-
Save mauricioaniche/8661de53ea80246abd0930d62e8499ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> df | |
r_correct r_deserved_grade r_guess r_to_pass r_prob | |
1 0 0.00 40 23 0.001288255 | |
2 1 0.25 39 22 0.002026315 | |
3 2 0.50 38 21 0.003423564 | |
4 3 0.75 37 20 0.006220180 | |
5 4 1.00 36 19 0.012010891 | |
6 5 1.25 35 18 0.024172832 | |
7 6 1.50 34 17 0.049693691 | |
8 7 1.75 33 16 0.102629931 | |
9 8 2.00 32 15 0.210340863 | |
10 9 2.25 31 14 0.424088520 | |
11 10 2.50 30 13 0.835777412 | |
12 11 2.75 29 12 1.601882250 | |
13 12 3.00 28 11 2.972850586 | |
14 13 3.25 27 10 5.320058407 | |
15 14 3.50 26 9 9.142002221 | |
16 15 3.75 25 8 15.019021384 | |
17 16 4.00 24 7 23.479922196 | |
18 17 4.25 23 6 34.761123278 | |
19 18 4.50 22 5 48.498637220 | |
20 19 4.75 21 4 63.495827014 | |
21 20 5.00 20 3 77.801516427 | |
22 21 5.25 19 2 89.288350784 | |
23 22 5.50 18 1 96.617373932 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
number_of_options_per_question = 4 | |
passing_grade = 5.75 / 10 | |
total_questions = 40 | |
points_per_question = 1 / total_questions | |
prob <- function(to_pass, total_questions) { | |
total = 0 | |
for(i in seq(1, to_pass)) { | |
total = total + dbinom(i, total_questions, 1/number_of_options_per_question) | |
} | |
return(1-total) | |
} | |
r_correct <- c() | |
r_guess <- c() | |
r_prob <- c() | |
r_to_pass <- c() | |
r_deserved_grade <- c() | |
# 'how many correct' represents how many questions the student actually knows and doesn't have to guess | |
for(how_many_correct in seq(0,(total_questions*passing_grade)-1)) { | |
# how many questions does she still need to pass? | |
questions_to_pass = passing_grade / points_per_question - how_many_correct | |
if(questions_to_pass<=0) | |
next | |
# how many questions can she guess? | |
how_many_to_guess = total_questions - how_many_correct | |
pass_prob <- prob(questions_to_pass, how_many_to_guess) | |
r_correct <- c(r_correct, how_many_correct) | |
r_deserved_grade <- c(r_deserved_grade, how_many_correct/total_questions * 10) | |
r_to_pass <- c(r_to_pass, questions_to_pass) | |
r_guess <- c(r_guess, how_many_to_guess) | |
r_prob <- c(r_prob, pass_prob*100) | |
} | |
df<-data.frame(r_correct, r_deserved_grade, r_guess, r_to_pass, r_prob) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment