11import numpy as np
22
3+ from pymc import Bernoulli , Censored , Mixture
34from pymc .aesaraf import floatX
45from pymc .distributions import (
56 DirichletMultinomial ,
@@ -48,9 +49,14 @@ def setup_class(self):
4849 # )
4950 nb2 = NegativeBinomial ("nb_with_p_n" , p = Uniform ("nbp" ), n = 10 )
5051
51- # Symbolic distribution
52+ # SymbolicRV
5253 zip = ZeroInflatedPoisson ("zip" , 0.5 , 5 )
5354
55+ # Nested SymbolicRV
56+ comp_1 = ZeroInflatedPoisson .dist (0.5 , 5 )
57+ comp_2 = Censored .dist (Bernoulli .dist (0.5 ), - 1 , 1 )
58+ nested_mix = Mixture ("nested_mix" , [0.5 , 0.5 ], [comp_1 , comp_2 ])
59+
5460 # Expected value of outcome
5561 mu = Deterministic ("mu" , floatX (alpha + dot (X , b )))
5662
@@ -80,7 +86,7 @@ def setup_class(self):
8086 # add a potential as well
8187 pot = Potential ("pot" , mu ** 2 )
8288
83- self .distributions = [alpha , sigma , mu , b , Z , nb2 , zip , Y_obs , pot ]
89+ self .distributions = [alpha , sigma , mu , b , Z , nb2 , zip , nested_mix , Y_obs , pot ]
8490 self .deterministics_or_potentials = [mu , pot ]
8591 # tuples of (formatting, include_params
8692 self .formats = [("plain" , True ), ("plain" , False ), ("latex" , True ), ("latex" , False )]
@@ -93,6 +99,11 @@ def setup_class(self):
9399 r"Z ~ N(f(), f())" ,
94100 r"nb_with_p_n ~ NB(10, nbp)" ,
95101 r"zip ~ MarginalMixture(f(), DiracDelta(0), Pois(5))" ,
102+ (
103+ r"nested_mix ~ MarginalMixture(<constant>, "
104+ r"MarginalMixture(f(), DiracDelta(0), Pois(5)), "
105+ r"Censored(Bern(0.5), -1, 1))"
106+ ),
96107 r"Y_obs ~ N(mu, sigma)" ,
97108 r"pot ~ Potential(f(beta, alpha))" ,
98109 ],
@@ -104,6 +115,7 @@ def setup_class(self):
104115 r"Z ~ N" ,
105116 r"nb_with_p_n ~ NB" ,
106117 r"zip ~ MarginalMixture" ,
118+ r"nested_mix ~ MarginalMixture" ,
107119 r"Y_obs ~ N" ,
108120 r"pot ~ Potential" ,
109121 ],
@@ -115,6 +127,11 @@ def setup_class(self):
115127 r"$\text{Z} \sim \operatorname{N}(f(),~f())$" ,
116128 r"$\text{nb_with_p_n} \sim \operatorname{NB}(10,~\text{nbp})$" ,
117129 r"$\text{zip} \sim \operatorname{MarginalMixture}(f(),~\text{\$\operatorname{DiracDelta}(0)\$},~\text{\$\operatorname{Pois}(5)\$})$" ,
130+ (
131+ r"$\text{nested_mix} \sim \operatorname{MarginalMixture}(\text{<constant>},"
132+ r"~\text{\$\operatorname{MarginalMixture}(f(),~\text{\\$\operatorname{DiracDelta}(0)\\$},~\text{\\$\operatorname{Pois}(5)\\$})\$},"
133+ r"~\text{\$\operatorname{Censored}(\text{\\$\operatorname{Bern}(0.5)\\$},~-1,~1)\$})$"
134+ ),
118135 r"$\text{Y_obs} \sim \operatorname{N}(\text{mu},~\text{sigma})$" ,
119136 r"$\text{pot} \sim \operatorname{Potential}(f(\text{beta},~\text{alpha}))$" ,
120137 ],
@@ -126,6 +143,7 @@ def setup_class(self):
126143 r"$\text{Z} \sim \operatorname{N}$" ,
127144 r"$\text{nb_with_p_n} \sim \operatorname{NB}$" ,
128145 r"$\text{zip} \sim \operatorname{MarginalMixture}$" ,
146+ r"$\text{nested_mix} \sim \operatorname{MarginalMixture}$" ,
129147 r"$\text{Y_obs} \sim \operatorname{N}$" ,
130148 r"$\text{pot} \sim \operatorname{Potential}$" ,
131149 ],
0 commit comments