![]() |
Create a random variable for Mixture.
Aliases:
tfp.edward2.Mixture(
*args,
**kwargs
)
See Mixture for more details.
Returns:
RandomVariable.
Original Docstring for Distribution
Initialize a Mixture distribution.
A Mixture
is defined by a Categorical
(cat
, representing the
mixture probabilities) and a list of Distribution
objects
all having matching dtype, batch shape, event shape, and continuity
properties (the components).
The num_classes
of cat
must be possible to infer at graph construction
time and match len(components)
.
Args:
cat
: ACategorical
distribution instance, representing the probabilities ofdistributions
.components
: A list or tuple ofDistribution
instances. Each instance must have the same type, be defined on the same domain, and have matchingevent_shape
andbatch_shape
.validate_args
: Pythonbool
, defaultFalse
. IfTrue
, raise a runtime error if batch or event ranks are inconsistent between cat and any of the distributions. This is only checked if the ranks cannot be determined statically at graph construction time.allow_nan_stats
: Boolean, defaultTrue
. IfFalse
, raise an exception if a statistic (e.g. mean/mode/etc...) is undefined for any batch member. IfTrue
, batch members with valid parameters leading to undefined statistics will return NaN for this statistic.use_static_graph
: Calls tosample
will not rely on dynamic tensor indexing, allowing for some static graph compilation optimizations, but at the expense of sampling all underlying distributions in the mixture. (Possibly useful when running on TPUs). Default value:False
(i.e., use dynamic indexing).name
: A name for this distribution (optional).
Raises:
TypeError
: If cat is not aCategorical
, orcomponents
is not a list or tuple, or the elements ofcomponents
are not instances ofDistribution
, or do not have matchingdtype
.ValueError
: Ifcomponents
is an empty list or tuple, or its elements do not have a statically known event rank. Ifcat.num_classes
cannot be inferred at graph creation time, or the constant value ofcat.num_classes
is not equal tolen(components)
, or allcomponents
andcat
do not have matching static batch shapes, or all components do not have matching static event shapes.