-
Notifications
You must be signed in to change notification settings - Fork 5
/
draws_test.go
54 lines (44 loc) · 893 Bytes
/
draws_test.go
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
package trueskill
import (
"math"
"testing"
)
const (
ErrTolerance float64 = 1e-06
)
func TestDrawMarginFromDrawProbability(t *testing.T) {
beta := 25.0 / 6
pDraw := []float64{
0.10,
0.25,
0.33}
epsilon := []float64{
0.74046637542690541,
1.87760059883033,
2.5111010132487492,
}
for i, p := range pDraw {
e := GetDrawMargin(p, beta, 2)
if math.Abs(e-epsilon[i]) > ErrTolerance {
t.Error("Expected draw margin for", p, "=", epsilon[i], "got", e)
}
}
}
func TestGetDrawProbabilityFromDrawMargin(t *testing.T) {
beta := 25.0 / 6
epsilon := []float64{
0.74046637542690541,
1.87760059883033,
2.5111010132487492,
}
pDraw := []float64{
0.10,
0.25,
0.33}
for i, e := range epsilon {
p := GetDrawProbability(e, beta, 2)
if math.Abs(p-pDraw[i]) > ErrTolerance {
t.Error("Expected draw probability for", e, "=", pDraw[i], "got", p)
}
}
}