upd readme
This commit is contained in:
31
tracking/test_cases/q5/1-DiscreteDist.test
Normal file
31
tracking/test_cases/q5/1-DiscreteDist.test
Normal file
@ -0,0 +1,31 @@
|
||||
class: "OutputTest"
|
||||
success: "PASS"
|
||||
failure: "NO PASS"
|
||||
|
||||
# Python statements initializing variables for the test below.
|
||||
preamble: """
|
||||
import inference
|
||||
|
||||
dist = inference.DiscreteDistribution()
|
||||
dist['a'] = 1
|
||||
dist['b'] = 2
|
||||
dist['c'] = 2
|
||||
dist['d'] = 0
|
||||
dist['e'] = 1
|
||||
N = 100000.0
|
||||
samples = [dist.sample() for _ in range(int(N))]
|
||||
ans1 = round(samples.count('a') * 1.0/N, 2)
|
||||
ans2 = round(samples.count('b') * 1.0/N, 2)
|
||||
ans3 = round(samples.count('c') * 1.0/N, 2)
|
||||
ans4 = round(samples.count('d') * 1.0/N, 2)
|
||||
ans5 = round(samples.count('e') * 1.0/N, 2)
|
||||
|
||||
ans = map(float, [ans1, ans2, ans3, ans4, ans5])
|
||||
"""
|
||||
|
||||
# A python expression to be evaluated. This expression must return the
|
||||
# same result for the student and instructor's code.
|
||||
|
||||
test: "ans"
|
||||
|
||||
|
Reference in New Issue
Block a user