# Distribution

abstract class Distribution<Value> < Object

Probability distribution.

• Value: Value type.

### Member Variables

Name Description
future:Value? Future value. This is set for situations where delayed sampling is used, but when ultimately realized, a particular value (this one) should be assigned, and updates or downdates applied accordingly. It is typically used when replaying traces.
futureUpdate:Boolean When assigned, should the future value trigger an update? (Otherwise a downdate.)
delay:DelayValue<Value>? Associated node on delayed sampling $M$-path.

### Member Functions

Name Description
value Realize a value for a random variate associated with the distribution, updating the delayed sampling graph accordingly.
assume Assume a distribution for this random variate.
assume Assume a distribution for this random variate.
assumeWithDowndate Assume a distribution for this random variate.
assumeWithDowndate Assume a distribution for this random variate.
set Realize a value for a random variate associated with the distribution, updating the delayed sampling graph accordingly.
setWithDowndate Realize a value for a random variate associated with the distribution, downdating the delayed sampling graph accordingly.
observe Observe a value for a random variate associated with the distribution, updating the delayed sampling graph accordingly, and returning a weight giving the log pdf (or pmf) of that variate under the distribution.
observeWithDowndate Observe a value for a random variate associated with the distribution, downdating the delayed sampling graph accordingly, and returning a weight giving the log pdf (or pmf) of that variate under the distribution.
simulate Simulate a random variate.
update Update the parameters of the distribution with a given value.
downdate Downdate the parameters of the distribution with a given value.
logpdf Evaluate the probability density (or mass) function, if it exists.
pdf Evaluate the probability density (or mass) function, if it exists.
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.
valueForward As value(), but forcing a forward simulation.
observeForward As observe(), but forcing a forward evaluation.
graft Graft this onto the delayed sampling graph.
detach Detach this from the delayed sampling graph.

### Member Function Details

#### assume

function assume(v:Random<Value>)

Assume a distribution for this random variate. When a value is required, it will be simulated from this distribution and trigger an update on the delayed sampling graph.

function assume(v:Random<Value>, future:Value)

Assume a distribution for this random variate. When a value is required, it will be assigned according to the future value given here, and trigger an update on the delayed sampling graph.

• dist: The distribution.
• future: The future value.

#### assumeWithDowndate

function assumeWithDowndate(v:Random<Value>)

Assume a distribution for this random variate. When a value is required, it will be simulated from this distribution and trigger a downdate on the delayed sampling graph.

function assumeWithDowndate(v:Random<Value>, future:Value)

Assume a distribution for this random variate. When a value is required, it will be assigned according to the future value given here, and trigger a downdate on the delayed sampling graph.

• dist: The distribution.
• future: The future value.

#### cdf

function cdf(x:Value) -> Real?

Evaluate the cumulative distribution function at a value.

• x: The value.

Return: the cumulative probability.

#### detach

function detach()

Detach this from the delayed sampling graph.

#### downdate

function downdate(x:Value)

Downdate the parameters of the distribution with a given value. This undoes the effects of an update().

• x: The value.

#### graft

abstract function graft(force:Boolean)

Graft this onto the delayed sampling graph.

• force: If true, a node is always grafted onto the delayed sampling graph, even if it has no parent. If false, no node is grafted in this case.

#### logpdf

function logpdf(x:Value) -> Real

Evaluate the probability density (or mass) function, if it exists.

• x: The value.

Return: the log probability density (or mass).

#### lower

function lower() -> Value?

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

#### observe

function observe(x:Value) -> Real

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

#### observeForward

abstract function observeForward(x:Value) -> Real

As observe(), but forcing a forward evaluation. See valueForward() for further details.

#### observeWithDowndate

function observeWithDowndate(x:Value) -> Real

Observe a value for a random variate associated with the distribution, downdating the delayed sampling graph accordingly, and returning a weight 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, if it exists.

• x: The value.

Return: the probability density (or mass).

#### quantile

function quantile(p:Real) -> Value?

Evaluate the quantile function at a cumulative probability.

• x: The cumulative probability.

Return: the quantile.

#### set

function set(x:Value) -> Value

Realize a value for a random variate associated with the distribution, updating the delayed sampling graph accordingly.

#### setWithDowndate

function setWithDowndate(x:Value) -> Value

Realize a value for a random variate associated with the distribution, downdating the delayed sampling graph accordingly.

#### simulate

function simulate() -> Value

Simulate a random variate.

Return: The simulated value.

#### update

function update(x:Value)

Update the parameters of the distribution with a given value.

Return: The value.

#### upper

function upper() -> Value?

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

#### value

function value() -> Value

Realize a value for a random variate associated with the distribution, updating the delayed sampling graph accordingly.

#### valueForward

abstract function valueForward() -> Value

As value(), but forcing a forward simulation. This requires that the distribution has not already grafted a node onto the delayed sampling graph. To ensure consistency it may, as a side effect, realize one or more nodes on that graph. This is typically useful where:

• only one variate will be simulated from the distribution, or
• there are no upstream nodes to marginalize.

In these situations delayed sampling will not provide any benefit, and this function avoids the overhead of delayed sampling graph updates.