22
22
Natbig = array ([0 , 3 ,4 ,5 , 1000 ], 'int64' )
23
23
24
24
25
+ def test_unif ():
26
+ checkd (Uniform , Runif , {'lower' : - Rplusunif , 'upper' : Rplusunif })
25
27
26
- def test_distributions ():
28
+ def test_flat ():
29
+ checkd (Flat , Runif , {}, False )
27
30
28
- yield checkd , Uniform , Runif , {'lower' : - Rplusunif , 'upper' : Rplusunif }
29
- yield checkd , Normal , R , {'mu' : R , 'tau' : Rplus }
30
- yield checkd , Beta , Unit , {'alpha' : Rplus * 5 , 'beta' : Rplus * 5 }
31
- yield checkd , Exponential , Rplus , {'lam' : Rplus }
32
- yield checkd , T , R , {'nu' : Rplus , 'mu' : R , 'lam' : Rplus }
33
- yield checkd , Cauchy , R , {'alpha' : R , 'beta' : Rplusbig }
34
- yield checkd , Gamma , Rplus , {'alpha' : Rplusbig , 'beta' : Rplusbig }
31
+ def test_normal ():
32
+ checkd (Normal , R , {'mu' : R , 'tau' : Rplus })
35
33
34
+ def test_beta ():
35
+ checkd (Beta , Unit , {'alpha' : Rplus * 5 , 'beta' : Rplus * 5 })
36
36
37
- yield checkd , Binomial , Nat , {'n' : Natbig , 'p' : Unit }
38
- yield checkd , BetaBin , Nat , {'alpha' : Rplus , 'beta' : Rplus , 'n' : Natbig }
39
- yield checkd , Bernoulli , Bool , {'p' : Unit }
40
- yield checkd , Poisson , Nat , {'mu' : Rplus }
41
- yield checkd , ConstantDist , I , {'c' : I }
37
+ def test_exponential ():
38
+ checkd (Exponential , Rplus , {'lam' : Rplus })
42
39
40
+ def test_laplace ():
41
+ checkd (Laplace , R , {'mu' : R , 'b' : Rplus })
43
42
43
+ def test_t ():
44
+ checkd (T , R , {'nu' : Rplus , 'mu' : R , 'lam' : Rplus })
44
45
46
+ def test_cauchy ():
47
+ checkd (Cauchy , R , {'alpha' : R , 'beta' : Rplusbig })
45
48
46
- def checkd (distfam , valuedomain , vardomains ):
49
+ def test_gamma ():
50
+ checkd (Gamma , Rplus , {'alpha' : Rplusbig , 'beta' : Rplusbig })
51
+
52
+ def test_tpos ():
53
+ checkd (Tpos , Rplus , {'nu' : Rplus , 'mu' : R , 'lam' : Rplus }, False )
54
+
55
+
56
+ def test_binomial ():
57
+ checkd (Binomial , Nat , {'n' : Natbig , 'p' : Unit })
58
+
59
+ def test_betabin ():
60
+ checkd (BetaBin , Nat , {'alpha' : Rplus , 'beta' : Rplus , 'n' : Natbig })
61
+
62
+ def test_bernoulli ():
63
+ checkd (Bernoulli , Bool , {'p' : Unit })
64
+
65
+ def test_poisson ():
66
+ checkd (Poisson , Nat , {'mu' : Rplus })
67
+
68
+ def test_constantdist ():
69
+ checkd (ConstantDist , I , {'c' : I })
70
+
71
+
72
+ def checkd (distfam , valuedomain , vardomains , check_int = True , check_der = True ):
47
73
48
74
m = Model ()
49
75
@@ -55,8 +81,10 @@ def checkd(distfam, valuedomain, vardomains):
55
81
56
82
domains = [np .array (vardomains [str (v )]) for v in m .vars ]
57
83
58
- check_int_to_1 (m , value , domains )
59
- check_dlogp (m , value , domains )
84
+ if check_int :
85
+ check_int_to_1 (m , value , domains )
86
+ if check_der :
87
+ check_dlogp (m , value , domains )
60
88
61
89
62
90
def check_int_to_1 (model , value , domains ):
0 commit comments