Skip to content

Commit 493a938

Browse files
committed
add gaussian mixture example
1 parent 198d13e commit 493a938

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

pymc3/distributions/mixture.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,29 @@ class NormalMixture(Mixture):
602602
of the mixture distribution, with one axis being
603603
the number of components.
604604
605-
Note: You only have to pass in sigma or tau, but not both.
605+
Notes
606+
-----
607+
You only have to pass in sigma or tau, but not both.
608+
609+
Examples
610+
--------
611+
.. code-block:: python
612+
613+
n_components = 3
614+
615+
with pm.Model() as gauss_mix:
616+
μ = pm.Normal(
617+
"μ",
618+
data.mean(),
619+
10,
620+
shape=n_components,
621+
transform=pm.transforms.ordered,
622+
testval=[1, 2, 3],
623+
)
624+
σ = pm.HalfNormal("σ", 10, shape=n_components)
625+
weights = pm.Dirichlet("w", np.ones(n_components))
626+
627+
pm.NormalMixture("y", w=weights, mu=μ, sigma=σ, observed=data)
606628
"""
607629

608630
def __init__(self, w, mu, sigma=None, tau=None, sd=None, comp_shape=(), *args, **kwargs):

0 commit comments

Comments
 (0)