dist_mixture

dist_mixture(components, weights, zero_inflated=False, zero_weight=0.0)

Mixture distribution.

A weighted mixture of component distributions, optionally zero-inflated. Mirrors the C# Mixture composite.

Parameters

Name Type Description Default
components sequence of Distribution The mixture components. required
weights array-like of float Mixture weights, the same length as components. required
zero_inflated bool Whether the mixture places extra probability mass at zero. False
zero_weight float The probability mass at zero when zero_inflated is True; ignored otherwise. 0.0

Returns

Name Type Description
Distribution Family "Mixture", accepted by every method every other :class:Distribution accepts.

Examples

>>> d = dist_mixture(
...     [Distribution("Normal", [0, 1]), Distribution("Normal", [5, 1])],
...     weights=[0.5, 0.5],
... )
>>> d.pdf(2.5) > 0
True