问题描述
BCS 2级考试有6个多项选择题,其中有4个选择,每个都有一个正确答案。如果仅对6个问题中的每一个进行随机猜测,那么准确地获得3个问题的概率是多少?
解决方法
这个问题是关于二项分布https://en.wikipedia.org/wiki/Binomial_distribution
对于任何单个问题,您只有p_wrong = 3/4,因为只有1/4正确。然后,您要问P(3错误| 6次试验)“给定6次试验3次错误的概率”。
P(3错误| 6)=(6选择3)(3/4)^ 3(1/4)^ 3
6选择3 = 6! / 3!(6-3)! = 4 5 6 /(3 2 1)= 20
于是20 *(3/4)^ 3(1/4)^ 3 = 0.1318359375
编辑您可以通过以下方式在Python中进行模拟:
import random
def sim(k,N):
trial_count = 0
for i in range(N):
# simulate a 6 question test
test_count = 0
for j in range(6):
# we'll say you got it right if you get a 1,else it's wrong
c = random.randint(1,4)
if c == 1:
test_count += 1
# after the test see how many they got right,if it's k
if test_count == k:
trial_count += 1
# after all the trials return the probability
return trial_count/N
# getting exactly 3 wrong on a 6 Q test is the same as exactly 3 right
print(sim(3,1_000_000)
或在APL中短一点;)
sim←{(+/⍺=+/1=?⍵ 6⍴(6×⍵)/4)÷⍵}
3 sim 1e6