Skip to content

Handler


final class Handler(autoconj:Boolean, autodiff:Boolean, autojoin:Boolean)

Event handler.

  • autoconj Enable delayed sampling.
  • autodiff Enable delayed expressions.

Events are triggered as code executes. Each event is handled via a call to the currently-installed event handler, which is an object of type Handler.

The events are:

Code Triggers
x ~ p handleAssume
x <~ p handleSimulate
x ~> p handleObserve
factor w handleFactor

After x ~ p, certain operations on x may further trigger events:

Code Triggers
x.value()/x.eval() handleDelaySimulate
x <- y handleDelayObserve

Finally, any manipulations of a Random x that is an interior node on the delayed sampling M-path will require pruning of the path, which will trigger handleDelayPrune.

Member Variables

Name Description
Ξ:Array<Delay> Distribution and Random objects for move.
Φ:Array<Expression<Real>> Factors for move.
w:Real! Accumulated eager weight.
autoconj:Boolean Enable automatic conjugacy (marginalization, conditioning, enumeration)?
autodiff:Boolean Enable automatic differentiation?
autojoin:Boolean Enable automatic joins? Requires automatic differentiation also.

Member Functions

Name Description
handleAssume Handle an assume event.
handleSimulate Handle a simulate event.
handleObserve Handle an observe event.
handleSimulate Handle a simulate event.
handleObserve Handle an observe event.
handleDelaySimulate Handle a delayed simulation event.
handleDelayObserve Handle a delayed observation event.
handleDelayPrune Handle a prune event.
handleFactor Handle a factor event.
handleFactor Handle a factor event.
handleFactor Handle a factor event.

Member Function Details

handleAssume

function handleAssume<Value>(x:Random<Value>, p:Distribution<Value>) -> Random<Value>

Handle an assume event.

  • x Random.
  • p Distribution.

Returns x.

handleDelayObserve

function handleDelayObserve<Value>(x:Random<Value>)

Handle a delayed observation event.

  • x Random.

handleDelayPrune

function handleDelayPrune<Value>(p:Distribution<Value>, x:Expression<Value>) -> Delay

Handle a prune event.

  • p Distribution.
  • x Child of p on M-path.

Returns Updated distribution.

handleDelaySimulate

function handleDelaySimulate<Value>(x:Random<Value>)

Handle a delayed simulation event.

  • x Random.

handleFactor

function handleFactor(φ:Real)

Handle a factor event.

@param φ Factor giving an incremental log-weight.

A factor event is triggered by the factor statement.

function handleFactor(φ:Real!)

Handle a factor event.

@param φ Factor giving an incremental log-weight.

A factor event is triggered by the factor statement.

function handleFactor<Arg>(φ:Arg)

Handle a factor event.

@param φ Factor giving an incremental log-weight.

A factor event is triggered by the factor statement.

handleObserve

function handleObserve<Value>(x:Random<Value>, p:Distribution<Value>) -> Random<Value>

Handle an observe event.

  • x Random.
  • p Distribution.

Returns x.

function handleObserve<Value>(x:Value, p:Distribution<Value>) -> Value

Handle an observe event.

  • x Variate.
  • p Distribution.

Returns x.

handleSimulate

function handleSimulate<Value>(x:Random<Value>, p:Distribution<Value>) -> Random<Value>

Handle a simulate event.

  • x Random.
  • p Distribution.

Returns x.

function handleSimulate<Value>(p:Distribution<Value>) -> Value

Handle a simulate event.

  • p Distribution.

Returns x.