Skip to content

Normalization constants #5

Open
@sethaxen

Description

@sethaxen

The goal of this issue is to discuss interfaces for dropping expensive/intractible normalization constants.

Each density $p(x|\theta)$ can be broken down into $p(x|\theta) = f(x, \theta) g(\theta) c$:

  • $f(x, \theta)$: a "kernel". This contains everything needed for certain methods, generalize those for which $\theta$ is fixed, e.g. $f$ can be used as a prior in MCMC if $\theta$ is fixed, and it can be a proposal/target in self-normalized importance sampling of $x$.
  • $g(\theta)$: Generally a scaled integral over $f(x, \theta)$. This is usually intractible, though for a select few named distributions it can be computed (sometimes expensively) using special functions. This is required whenever $\theta$ is not fixed, and for many distributions and inference methods it must be differentiable.
  • $c$ is a constant factor dependent on the manifold and choice of measure (and its normalization convention). It's only needed if the method requires that the pdf be normalized to 1. The only method I can think of that would require this is importance sampling (not self-normalized).

In Distributions' own implementations, pdf always computes the full $p$. To reduce the cost of repeated evaluations of pdf, $c g(\theta)$ is often pre-computed in the constructor.

In adhering to Distributions' own API, we can't assume what users will use pdf/logpdf for, so we would ideally return the full $p$. But this is often very expensive or intractible. We could use keywords to pdf/logpdf to specify which is computed, but we can't expect downstream packages to have support for those (e.g. Turing users never call logpdf themselves).

Currently the best way I can think of to support this is either

  1. Every family gets a field that specifies its normalization.
  2. We by default just return the "kernel" and have a wrapper (e.g. Normalized) for any distribution that guarantees normalization constants are computed (or raises an error if not implemented).

(1) provides a nice terse syntax, while (2) increases code complexity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions