Create a random variable for MixtureSameFamily.

See MixtureSameFamily for more details.



Original Docstring for Distribution

Construct a MixtureSameFamily distribution.


  • mixture_distribution: tfp.distributions.Categorical-like instance. Manages the probability of selecting components. The number of categories must match the rightmost batch dimension of the components_distribution. Must have either scalar batch_shape or batch_shape matching components_distribution.batch_shape[:-1].
  • components_distribution: tfp.distributions.Distribution-like instance. Right-most batch dimension indexes components.
  • validate_args: Python bool, default False. When True distribution parameters are checked for validity despite possibly degrading runtime performance. When False invalid inputs may silently render incorrect outputs.
  • allow_nan_stats: Python bool, default True. When True, statistics (e.g., mean, mode, variance) use the value "NaN" to indicate the result is undefined. When False, an exception is raised if one or more of the statistic's batch members are undefined.
  • name: Python str name prefixed to Ops created by this class.


  • ValueError: if not mixture_distribution.dtype.is_integer.
  • ValueError: if mixture_distribution does not have scalar event_shape.
  • ValueError: if mixture_distribution.batch_shape and components_distribution.batch_shape[:-1] are both fully defined and the former is neither scalar nor equal to the latter.
  • ValueError: if mixture_distribution categories does not equal components_distribution rightmost batch shape.