19
19
Laplace ,
20
20
Logistic ,
21
21
LogNormal ,
22
+ NegativeBinomial ,
22
23
Poisson ,
23
24
StudentT ,
24
25
Weibull ,
26
+ ZeroInflatedBinomial ,
27
+ ZeroInflatedPoisson ,
25
28
)
26
29
from pymc .distributions .shape_utils import rv_size_is_none
27
30
from pymc .initial_point import make_initial_point_fn
@@ -402,6 +405,21 @@ def test_poisson_moment(mu, size, expected):
402
405
assert_moment_is_expected (model , expected )
403
406
404
407
408
+ @pytest .mark .parametrize (
409
+ "n, p, size, expected" ,
410
+ [
411
+ (10 , 0.7 , None , 4 ),
412
+ (10 , 0.7 , 5 , np .full (5 , 4 )),
413
+ (np .full (3 , 10 ), np .arange (1 , 4 ) / 10 , None , np .array ([90 , 40 , 23 ])),
414
+ (10 , np .arange (1 , 4 ) / 10 , (2 , 3 ), np .full ((2 , 3 ), np .array ([90 , 40 , 23 ]))),
415
+ ],
416
+ )
417
+ def test_negative_binomial_moment (n , p , size , expected ):
418
+ with Model () as model :
419
+ NegativeBinomial ("x" , n = n , p = p , size = size )
420
+ assert_moment_is_expected (model , expected )
421
+
422
+
405
423
@pytest .mark .parametrize (
406
424
"c, size, expected" ,
407
425
[
@@ -416,6 +434,36 @@ def test_constant_moment(c, size, expected):
416
434
assert_moment_is_expected (model , expected )
417
435
418
436
437
+ @pytest .mark .parametrize (
438
+ "psi, theta, size, expected" ,
439
+ [
440
+ (0.9 , 3.0 , None , 2 ),
441
+ (0.8 , 2.9 , 5 , np .full (5 , 2 )),
442
+ (0.2 , np .arange (1 , 5 ) * 5 , None , np .arange (1 , 5 )),
443
+ (0.2 , np .arange (1 , 5 ) * 5 , (2 , 4 ), np .full ((2 , 4 ), np .arange (1 , 5 ))),
444
+ ],
445
+ )
446
+ def test_zero_inflated_poisson_moment (psi , theta , size , expected ):
447
+ with Model () as model :
448
+ ZeroInflatedPoisson ("x" , psi = psi , theta = theta , size = size )
449
+ assert_moment_is_expected (model , expected )
450
+
451
+
452
+ @pytest .mark .parametrize (
453
+ "psi, n, p, size, expected" ,
454
+ [
455
+ (0.2 , 7 , 0.7 , None , 4 ),
456
+ (0.2 , 7 , 0.3 , 5 , np .full (5 , 2 )),
457
+ (0.6 , 25 , np .arange (1 , 6 ) / 10 , None , np .arange (1 , 6 )),
458
+ (0.6 , 25 , np .arange (1 , 6 ) / 10 , (2 , 5 ), np .full ((2 , 5 ), np .arange (1 , 6 ))),
459
+ ],
460
+ )
461
+ def test_zero_inflated_binomial_moment (psi , n , p , size , expected ):
462
+ with Model () as model :
463
+ ZeroInflatedBinomial ("x" , psi = psi , n = n , p = p , size = size )
464
+ assert_moment_is_expected (model , expected )
465
+
466
+
419
467
@pytest .mark .parametrize (
420
468
"mu, s, size, expected" ,
421
469
[
0 commit comments