bijx.MixtureStack

class bijx.MixtureStack[source]

Bases: Distribution

Mixture of distributions of equal kind.

See also bijx.ScanChain for a related construct except for composing bijections instead of mixing distributions.

__init__(distributions, weights, *, rngs=None)[source]
Parameters:
  • distributions (Distribution)

  • weights (Variable | Array | ndarray | Sequence[int | Any])

Methods

density(x, **kwargs)

Evaluate probability density at given points.

get_batch_shape(x)

Extract batch dimensions from a sample.

log_density(x)

Evaluate log probability density at given points.

sample([batch_shape, rng])

Generate samples from the distribution.

Attributes

property weights_normalized
property weights_log_normalized
property stack
get_batch_shape(x)[source]

Extract batch dimensions from a sample.

Parameters:

x – A sample from this distribution.

Returns:

Tuple representing the batch dimensions of the sample.

log_density(x)[source]

Evaluate log probability density at given points.

Parameters:
  • x – Points at which to evaluate density, with event dimensions matching the distribution’s event shape.

  • **kwargs – Additional distribution-specific evaluation arguments.

Returns:

Log density values with batch dimensions matching input.

sample(batch_shape=(), rng=None)[source]

Generate samples from the distribution.

Parameters:
  • batch_shape – Shape of batch dimensions for vectorized sampling.

  • rng – Random key for sampling, or None to use internal rngs.

  • **kwargs – Additional distribution-specific sampling arguments.

Returns:

Tuple of (samples, log_densities) where samples have shape (*batch_shape, *event_shape) and log_densities have shape batch_shape.