jeudi 31 décembre 2020

Best way of testing randomized function

Let's say I have a random number generator for 3 categories:

Prob Yield
0.1 10
0.2 5
0.7 2

The expected yield is 1 + 1 + 1.4 = 3.4

Currently I have something like this

sum = 0
N = 10000
for i in 1 to N:
    sum += getYeild()
assert(sum / N - 3.14 < some threshold)

So what is the best criterion I can use for this unit test to make an assertion?




Aucun commentaire:

Enregistrer un commentaire