Mixture¶
Mixture (w, comp_dists, *args, **kwargs) 
Mixture loglikelihood 
NormalMixture (w, mu[, comp_shape]) 
Normal mixture loglikelihood 

class
pymc3.distributions.mixture.
Mixture
(w, comp_dists, *args, **kwargs)¶ Mixture loglikelihood
Often used to model subpopulation heterogeneity
\[f(x \mid w, \theta) = \sum_{i = 1}^n w_i f_i(x \mid \theta_i)\]Support \(\cap_{i = 1}^n \textrm{support}(f_i)\) Mean \(\sum_{i = 1}^n w_i \mu_i\) Parameters:  w (array of floats) – w >= 0 and w <= 1 the mixture weights
 comp_dists (multidimensional PyMC3 distribution (e.g. pm.Poisson.dist(…))) – or iterable of onedimensional PyMC3 distributions the component distributions \(f_1, \ldots, f_n\)
Example
# 2Mixture Poisson distribution with pm.Model() as model: lam = pm.Exponential('lam', lam=1, shape=(2,)) # `shape=(2,)` indicates two mixtures. # As we just need the logp, rather than add a RV to the model, we need to call .dist() components = pm.Poisson.dist(mu=lam, shape=(2,)) w = pm.Dirichlet('w', a=np.array([1, 1])) # two mixture component weights. like = pm.Mixture('like', w=w, comp_dists=components, observed=data) # 2Mixture Poisson using iterable of distributions. with pm.Model() as model: lam1 = pm.Exponential('lam1', lam=1) lam2 = pm.Exponential('lam2', lam=1) pois1 = pm.Poisson.dist(mu=lam1) pois2 = pm.Poisson.dist(mu=lam2) w = pm.Dirichlet('w', a=np.array([1, 1])) like = pm.Mixture('like', w=w, comp_dists = [pois1, pois2], observed=data)

class
pymc3.distributions.mixture.
NormalMixture
(w, mu, comp_shape=(), *args, **kwargs)¶ Normal mixture loglikelihood
\[f(x \mid w, \mu, \sigma^2) = \sum_{i = 1}^n w_i N(x \mid \mu_i, \sigma^2_i)\]Support \(x \in \mathbb{R}\) Mean \(\sum_{i = 1}^n w_i \mu_i\) Variance \(\sum_{i = 1}^n w_i^2 \sigma^2_i\) Parameters:  w (array of floats) – w >= 0 and w <= 1 the mixture weights
 mu (array of floats) – the component means
 sd (array of floats) – the component standard deviations
 tau (array of floats) – the component precisions
 comp_shape (shape of the Normal component) – notice that it should be different than the shape of the mixture distribution, with one axis being the number of components.
 Note (You only have to pass in sd or tau, but not both.) –

pymc3.distributions.mixture.
all_discrete
(comp_dists)¶ Determine if all distributions in comp_dists are discrete