-
Notifications
You must be signed in to change notification settings - Fork 0
/
constant_test.go
57 lines (47 loc) · 1.1 KB
/
constant_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
55
56
57
package uncertainty
import "testing"
func TestConstantSample(t *testing.T) {
c := NewConstant(5.0)
m := Materialize(c, 10)
if m.First() != 5.0 {
t.Fatal("Couldn't retrieve constant after sampling")
}
}
func TestConstantBNNSample(t *testing.T) {
a := NewConstant(5.0)
b := NewConstant(6.0)
c := Add(a, b)
m := Materialize(c, 10)
if m.First() != 11.0 {
t.Fatal("Addition on constants failed")
}
}
func TestConstantBernoulliSample(t *testing.T) {
a := NewConstant(5.0)
b := NewConstant(6.0)
c := LessThan(b, a)
m := Materialize(c, 10)
if m.First() != 0.0 {
t.Fatal("LessThan on constants failed")
}
}
func TestBernoulliConditional(t *testing.T) {
x := NewConstant(5.0)
y := NewConstant(6.0)
if LessThan(y, x).Pr() {
t.Fatal("6 tests less than 5")
}
if !LessThan(x, y).Pr() {
t.Fatal("5 tests not less than 6")
}
}
func TestBernoulliEqual(t *testing.T) {
x := NewConstant(5.0)
y := NewConstant(5.0)
if LessThan(x, y).Pr() {
t.Fatal("x is less than y, incorrectly (they should be equal)")
}
if LessThan(y, x).Pr() {
t.Fatal("y is less than x, incorrectly (they should be equal)")
}
}