-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsat.R
63 lines (56 loc) · 1.27 KB
/
sat.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
p <- 1/5 # one correct choice of 5 options
a <- 1
b <- -0.25
mu <- a*p + b*(1-p)
n <- 44
n*mu
sigma <- sqrt(n) * abs(b-a) * sqrt(p*(1-p))
1-pnorm(8, mu, sigma)
set.seed(21, sample.kind = "Rounding")
# solution 1
# scores <- numeric(n)
#
# B <- 10000
# r_sat <- function(){
# X <- sample(c(-0.25, 1), n, replace = TRUE, prob = c(1 - p, p))
# scores <- sum(X)
# }
#
# m <- replicate(B, r_sat())
# mean(m >= 8)
# solution 2
B <- 10000
r_sat <- replicate(B, {
X <- sample(c(-0.25, 1), n, replace = TRUE, prob = c(1 - p, p))
sum(X)
})
mean(r_sat >= 8)
# The SAT was recently changed to reduce the number of multiple choice options
# from 5 to 4 and also to eliminate the penalty for guessing.
p <- 1/4 # one correct choice of 4 options
a <- 1
b <- 0
mu <- a*p + b*(1-p)
print(mu)
n <- 44
n*mu
p <- seq(0.25, 0.95, 0.05)
set.seed(21, sample.kind = "Rounding")
B <- 10000
n <- 44
p <- 0.25
tests <- replicate(B, {
X <- sample(c(1, 0), n, replace = TRUE, prob = c(p, 1-p))
sum(X)
})
mean(tests >= 30)
# solution
# What is the lowest p such that the probability of
# scoring over 35 exceeds 80%?
p <- seq(0.25, 0.95, 0.05)
exp_val <- sapply(p, function(x){
mu <- n * a*x + b*(1-x)
sigma <- sqrt(n) * abs(b-a) * sqrt(x*(1-x))
1-pnorm(35, mu, sigma)
})
min(p[which(exp_val > 0.8)])