beanmachine.ppl.distributions package

Submodules

Module contents

class beanmachine.ppl.distributions.Delta(v, log_density=0.0, event_dim=0, validate_args=None)

Bases: torch.distributions.distribution.Distribution

arg_constraints = {'log_density': Real(), 'v': Real()}
property event_dim
expand(batch_shape, _instance=None)

Returns a new distribution instance (or populates an existing instance provided by a derived class) with batch dimensions expanded to batch_shape. This method calls expand on the distribution’s parameters. As such, this does not allocate new memory for the expanded distribution instance. Additionally, this does not repeat any args checking or parameter broadcasting in __init__.py, when an instance is first created.

Parameters
  • batch_shape (torch.Size) – the desired expanded size.

  • _instance – new instance provided by subclasses that need to override .expand.

Returns

New distribution instance with batch dimensions expanded to batch_size.

has_rsample = True
log_prob(x)

Returns the log of the probability density/mass function evaluated at value.

Parameters

value (Tensor) –

property mean

Returns the mean of the distribution.

rsample(sample_shape=torch.Size([]))

Generates a sample_shape shaped reparameterized sample or sample_shape shaped batch of reparameterized samples if the distribution parameters are batched.

shape(sample_shape=torch.Size([]))
support = Real()
property variance

Returns the variance of the distribution.

class beanmachine.ppl.distributions.Flat(shape=(1,))

Bases: torch.distributions.distribution.Distribution

Flat distribution used as an improper prior. Samples 0 with shape sample shape

Args

shape: pass a tuple, and give a shape of Flat prior.

arg_constraints = {}
has_enumerate_support = False
has_rsample = True
log_prob(value)

Returns the log of the probability density/mass function evaluated at value.

Parameters

value (Tensor) –

rsample(sample_shape)

Generates a sample_shape shaped reparameterized sample or sample_shape shaped batch of reparameterized samples if the distribution parameters are batched.

sample()

Generates a sample_shape shaped sample or sample_shape shaped batch of samples if the distribution parameters are batched.

support = Real()
class beanmachine.ppl.distributions.Unit(log_factor, validate_args=None)

Bases: torch.distributions.distribution.Distribution

Trivial nonnormalized distribution representing the unit type.

The unit type has a single value with no data, i.e. value.numel() == 0.

This is used for pyro.factor() statements.

arg_constraints = {'log_factor': Real()}
expand(batch_shape, _instance=None)

Returns a new distribution instance (or populates an existing instance provided by a derived class) with batch dimensions expanded to batch_shape. This method calls expand on the distribution’s parameters. As such, this does not allocate new memory for the expanded distribution instance. Additionally, this does not repeat any args checking or parameter broadcasting in __init__.py, when an instance is first created.

Parameters
  • batch_shape (torch.Size) – the desired expanded size.

  • _instance – new instance provided by subclasses that need to override .expand.

Returns

New distribution instance with batch dimensions expanded to batch_size.

log_prob(value)

Returns the log of the probability density/mass function evaluated at value.

Parameters

value (Tensor) –

sample(sample_shape=torch.Size([]))

Generates a sample_shape shaped sample or sample_shape shaped batch of samples if the distribution parameters are batched.

support = Real()