# Distribution

abstract class Distribution<Value> < DelayDistribution

Distribution with delayed-sampling support.

• Value: Value type.

### Member Variables

Name Description
x:Random<Value>? Random variate associated with the distibution, if it is on the delayed sampling $M$-path.

### Member Functions

Name Description
rows Number of rows, when interpreted as a matrix.
columns Number of columns, when interpreted as a matrix.
supportsLazy Are lazy operations supported?
distribution Returns this; a convenience for code generation within the compiler.
setRandom Set a random variate associated with the distribution.
unsetRandom Unset the random variate associated with the distribution.
realize Realize the random variate associated with the distribution.
value Simulate a value for a random variate associated with this node, updating the delayed sampling graph accordingly, and returning the value.
observe Observe a value for a random variate associated with this node, updating the delayed sampling graph accordingly, and returning a weight giving the log pdf (or pmf) of that variate under the distribution.
observeLazy Observe a value for a random variate associated with this node, updating the delayed sampling graph accordingly, and returning a lazy expression giving the log pdf (or pmf) of that variate under the distribution.
simulate Simulate a value.
simulateLazy Simulate a value as part of a lazy expression.
logpdf Evaluate the log probability density (or mass) function.
logpdfLazy Construct a lazy expression for the log probability density (or mass).
update Update the parent node on the $M$-path given the value of this node.
updateLazy Update the parent node on the $M$-path given the value of this node.
pdf Evaluate the probability density (or mass) function.
cdf Evaluate the cumulative distribution function at a value.
quantile Evaluate the quantile function at a cumulative probability.
lower Finite lower bound of the support of this node, if any.
upper Finite upper bound of the support of this node, if any.
graft Graft this onto the delayed sampling graph.
graftGaussian Graft this onto the delayed sampling graph.
graftBeta Graft this onto the delayed sampling graph.
graftGamma Graft this onto the delayed sampling graph.
graftInverseGamma Graft this onto the delayed sampling graph.
graftIndependentInverseGamma Graft this onto the delayed sampling graph.
graftInverseWishart Graft this onto the delayed sampling graph.
graftNormalInverseGamma Graft this onto the delayed sampling graph.
graftDirichlet Graft this onto the delayed sampling graph.
graftRestaurant Graft this onto the delayed sampling graph.
graftMultivariateGaussian Graft this onto the delayed sampling graph.
graftMultivariateNormalInverseGamma Graft this onto the delayed sampling graph.
graftMatrixGaussian Graft this onto the delayed sampling graph.
graftMatrixNormalInverseGamma Graft this onto the delayed sampling graph.
graftMatrixNormalInverseWishart Graft this onto the delayed sampling graph.
graftDiscrete Graft this onto the delayed sampling graph.
graftBoundedDiscrete Graft this onto the delayed sampling graph.

### Member Function Details

#### cdf

function cdf(x:Value) -> Real?

Evaluate the cumulative distribution function at a value.

• x: The value.

Return: the cumulative probability, if supported.

#### columns

function columns() -> Integer

Number of columns, when interpreted as a matrix.

#### distribution

final function distribution() -> Distribution<Value>

Returns this; a convenience for code generation within the compiler.

#### graft

function graft() -> Distribution<Value>

Graft this onto the delayed sampling graph.

Returns: The object to attach to the delayed sampling graph. This may be this object, or a substitute based on variable elimination rules. Call attach() on the object to finalize the graft.

#### graftBeta

function graftBeta() -> Beta?

Graft this onto the delayed sampling graph.

#### graftBoundedDiscrete

function graftBoundedDiscrete() -> BoundedDiscrete?

Graft this onto the delayed sampling graph.

#### graftDirichlet

function graftDirichlet() -> Dirichlet?

Graft this onto the delayed sampling graph.

#### graftDiscrete

function graftDiscrete() -> Discrete?

Graft this onto the delayed sampling graph.

#### graftGamma

function graftGamma() -> Gamma?

Graft this onto the delayed sampling graph.

#### graftGaussian

function graftGaussian() -> Gaussian?

Graft this onto the delayed sampling graph.

#### graftIndependentInverseGamma

function graftIndependentInverseGamma() -> IndependentInverseGamma?

Graft this onto the delayed sampling graph.

#### graftInverseGamma

function graftInverseGamma() -> InverseGamma?

Graft this onto the delayed sampling graph.

#### graftInverseWishart

function graftInverseWishart() -> InverseWishart?

Graft this onto the delayed sampling graph.

#### graftMatrixGaussian

function graftMatrixGaussian() -> MatrixGaussian?

Graft this onto the delayed sampling graph.

#### graftMatrixNormalInverseGamma

function graftMatrixNormalInverseGamma(compare:Distribution<Real[_]>) -> MatrixNormalInverseGamma?

Graft this onto the delayed sampling graph.

#### graftMatrixNormalInverseWishart

function graftMatrixNormalInverseWishart(compare:Distribution<LLT>) -> MatrixNormalInverseWishart?

Graft this onto the delayed sampling graph.

#### graftMultivariateGaussian

function graftMultivariateGaussian() -> MultivariateGaussian?

Graft this onto the delayed sampling graph.

#### graftMultivariateNormalInverseGamma

function graftMultivariateNormalInverseGamma(compare:Distribution<Real>) -> MultivariateNormalInverseGamma?

Graft this onto the delayed sampling graph.

#### graftNormalInverseGamma

function graftNormalInverseGamma(compare:Distribution<Real>) -> NormalInverseGamma?

Graft this onto the delayed sampling graph.

#### graftRestaurant

function graftRestaurant() -> Restaurant?

Graft this onto the delayed sampling graph.

#### logpdf

abstract function logpdf(x:Value) -> Real

Evaluate the log probability density (or mass) function.

• x: The value.

Return: the log probability density (or mass).

#### logpdfLazy

function logpdfLazy(x:Expression<Value>) -> Expression<Real>?

Construct a lazy expression for the log probability density (or mass).

• x: The value.

Return: the log probability density (or mass), if supported.

#### lower

function lower() -> Value?

Finite lower bound of the support of this node, if any.

#### observe

final function observe(x:Value) -> Real

Observe a value for a random variate associated with this node, updating the delayed sampling graph accordingly, and returning a weight giving the log pdf (or pmf) of that variate under the distribution.

#### observeLazy

final function observeLazy(x:Expression<Value>) -> Expression<Real>?

Observe a value for a random variate associated with this node, updating the delayed sampling graph accordingly, and returning a lazy expression giving the log pdf (or pmf) of that variate under the distribution.

#### pdf

function pdf(x:Value) -> Real

Evaluate the probability density (or mass) function.

• x: The value.

Return: the probability density (or mass).

#### quantile

function quantile(P:Real) -> Value?

Evaluate the quantile function at a cumulative probability.

• P: The cumulative probability.

Return: the quantile, if supported.

#### realize

final function realize()

Realize the random variate associated with the distribution.

#### rows

function rows() -> Integer

Number of rows, when interpreted as a matrix.

#### setRandom

final function setRandom(x:Random<Value>)

Set a random variate associated with the distribution.

#### simulate

abstract function simulate() -> Value

Simulate a value.

Return: the value.

#### simulateLazy

function simulateLazy() -> Value?

Simulate a value as part of a lazy expression.

Return: the value, if supported.

#### supportsLazy

function supportsLazy() -> Boolean

Are lazy operations supported?

#### unsetRandom

final function unsetRandom(x:Random<Value>)

Unset the random variate associated with the distribution.

#### update

function update(x:Value)

Update the parent node on the $M$-path given the value of this node.

• x: The value.

#### updateLazy

function updateLazy(x:Expression<Value>)

Update the parent node on the $M$-path given the value of this node.

• x: The value.

#### upper

function upper() -> Value?

Finite upper bound of the support of this node, if any.

#### value

function value() -> Value

Simulate a value for a random variate associated with this node, updating the delayed sampling graph accordingly, and returning the value.