Distribution Funsors

This interface provides a number of standard normalized probability distributions implemented as funsors.

class Distribution(*args)[source]

Bases: funsor.terms.Funsor

Funsor backed by a PyTorch distribution object.

Parameters:*args – Distribution-dependent parameters. These can be either funsors or objects that can be coerced to funsors via to_funsor() . See derived classes for details.
dist_class = 'defined by derived classes'
eager_reduce(op, reduced_vars)[source]
classmethod eager_log_prob(**params)[source]
class BernoulliLogits(logits, value=None)[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Bernoulli .

Parameters:
  • logits (Funsor) – Log likelihood ratio of 1. This should equal log(p1 / p0).
  • value (Funsor) – Optional observation in {0,1}.
dist_class

alias of pyro.distributions.torch.Bernoulli

Bernoulli(probs=None, logits=None, value='value')[source]

Wraps pyro.distributions.Bernoulli .

This dispatches to either BernoulliProbs or BernoulliLogits to accept either probs or logits args.

Parameters:
  • probs (Funsor) – Probability of 1.
  • value (Funsor) – Optional observation in {0,1}.
class Beta(concentration1, concentration0, value=None)[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Beta .

Parameters:
  • concentration1 (Funsor) – Positive concentration parameter.
  • concentration0 (Funsor) – Positive concentration parameter.
  • value (Funsor) – Optional observation in (0,1).
dist_class

alias of pyro.distributions.torch.Beta

class Binomial(total_count, probs, value=None)[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Binomial .

Parameters:
  • total_count (Funsor) – Total number of trials.
  • probs (Funsor) – Probability of each positive trial.
  • value (Funsor) – Optional integer observation (encoded as “real”).
dist_class

alias of pyro.distributions.torch.Binomial

class Categorical(probs, value='value')[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Categorical .

Parameters:
  • probs (Funsor) – Probability vector over outcomes.
  • value (Funsor) – Optional bouded integer observation.
dist_class

alias of pyro.distributions.torch.Categorical

class Delta(v, log_density=0, value='value')[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Delta .

Parameters:
  • v (Funsor) – The unique point of concentration.
  • log_density (Funsor) – Optional density (used by transformed distributions).
  • value (Funsor) – Optional observation of similar domain as v.
dist_class

alias of pyro.distributions.delta.Delta

class Dirichlet(concentration, value='value')[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Dirichlet .

Parameters:
  • concentration (Funsor) – Positive concentration vector.
  • value (Funsor) – Optional observation in the unit simplex.
dist_class

alias of pyro.distributions.torch.Dirichlet

class DirichletMultinomial(concentration, total_count, value='value')[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.DirichletMultinomial .

Parameters:
  • concentration (Funsor) – Positive concentration vector.
  • total_count (Funsor) – Total number of trials.
  • value (Funsor) – Optional observation in the unit simplex.
dist_class

alias of pyro.distributions.conjugate.DirichletMultinomial

LogNormal(loc, scale, value='value')[source]

Wraps pyro.distributions.LogNormal .

Parameters:
  • loc (Funsor) – Mean of the untransformed Normal distribution.
  • scale (Funsor) – Standard deviation of the untransformed Normal distribution.
  • value (Funsor) – Optional real observation.
class Multinomial(total_count, probs, value=None)[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Multinomial .

Parameters:
  • probs (Funsor) – Probability vector over outcomes.
  • total_count (Funsor) – Total number of trials.
  • value (Funsor) – Optional value in the unit simplex.
dist_class

alias of pyro.distributions.torch.Multinomial

class Normal(loc, scale, value='value')[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Normal .

Parameters:
  • loc (Funsor) – Mean.
  • scale (Funsor) – Standard deviation.
  • value (Funsor) – Optional real observation.
dist_class

alias of pyro.distributions.torch.Normal

class MultivariateNormal(loc, scale_tril, value='value')[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.MultivariateNormal .

Parameters:
  • loc (Funsor) – Mean vector.
  • scale_tril (Funsor) – Lower Cholesky factor of the covariance matrix.
  • value (Funsor) – Optional real vector observation.
dist_class

alias of pyro.distributions.torch.MultivariateNormal

class Poisson(rate, value=None)[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Poisson .

Parameters:
  • rate (Funsor) – Mean parameter.
  • value (Funsor) – Optional integer observation (coded as “real”).
dist_class

alias of pyro.distributions.torch.Poisson

class Gamma(concentration, rate, value=None)[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.Gamma .

Parameters:
  • concentration (Funsor) – Positive concentration parameter.
  • rate (Funsor) – Positive rate parameter.
  • value (Funsor) – Optional positive observation.
dist_class

alias of pyro.distributions.torch.Gamma

class VonMises(loc, concentration, value=None)[source]

Bases: funsor.distributions.Distribution

Wraps pyro.distributions.VonMises .

Parameters:
  • loc (Funsor) – A location angle.
  • concentration (Funsor) – Positive concentration parameter.
  • value (Funsor) – Optional angular observation.
dist_class

alias of pyro.distributions.von_mises.VonMises