The name of the element
The element collection to which this element belongs
The type of conditions on the element.
The type of conditions on the element. A condition is a function from a value to a Boolean.
The type of soft constraints on the element.
The type of soft constraints on the element. A constraint is a function from a value to a Double.
The type of randomness content of the element.
The type of values over which the element is defined.
The arguments on which the element depends.
Generate the randomness content.
Generate the value of the element determinstically given its randomness and the values of its arguments.
The element that tests inequality of this element with another element.
The element that tests whether the value of this element is equal to a particular value.
The element that tests equality of this element with another element.
Activate the element in its universe.
Flag indicating whether the element is currently active in its universe.
Add the given condition to the existing conditions of the element.
Add the given condition to the existing conditions of the element. By default, the contingency is empty.
Add a contingent constraint to the element.
Add a contingent constraint to the element. By default, the contingency is empty.
Add a log contingent constraint to the element.
Add a log contingent constraint to the element. By default, the contingency is empty.
Add a pragma to the element.
All the conditions defined on this element.
The current soft constraints on the element.
Clears all the temporary elements associated with this element (all elements created in it's context)
The element collection to which this element belongs
Tests whether all the element's contingent conditions are satisfied for the given value.
Determines whether the condition on the element is satisfied by the current value.
Gets the result of all the element's contingent constraints for the given value.
Determines the value of the constraint on the element applied to the current value.
The elements on which the existence of this element depends
Deactivate the element in its universe.
Returns the set of elements directly created in the context of this element
First generate the randomness, then generate the value given the randomness.
First generate the randomness, then generate the value given the randomness. Store the results in randomness and value.
The cacheability of the element.
The cacheability of the element. Chains create caches of their parent values, and it is useful to know when these values can be effectively cached and reused. In general, continuous distributions are not cacheable
Returns true if this element is temporary, that is, was created in the context of another element
The name of the element
Generate the next randomness given the current randomness.
Generate the next randomness given the current randomness. Returns three values: The next randomness, the Metropolis-Hastings proposal probability ratio, which is
P(new -> old) / P(old -> new)
and the model probability ratio, which is
P(new) / P(old)
The default implementation is to use generateRandomness and returns ones for the proposal and model probability ratios.
Condition the element by observing a particular value.
Condition the element by observing a particular value. Propagates the effect to dependent elements and ensures that no other value for the element can be generated.
The pragmas attached to the element.
The current randomness content of the element.
Remove all conditions associated with the given contingency.
Remove all conditions associated with the given contingency. By default, the contingency is empty.
Remove all constraints associated with the given contingency.
Remove all constraints associated with the given contingency. By default, the contingency is empty.
Remove a pragma from the element.
Compute the constraints on the new value divided by the constraints on the old value.
Set the value of this element and propagate the effects to elements that depend on it without changing their randomness.
Set the value of this element and propagate the effects to elements that depend on it without changing their randomness. Also disallows the value of the element to change until unobserve or unset is called.
Set the condition associated with the contingency.
Set the condition associated with the contingency. Removes previous conditions associated with the contingency. By default, the contingency is empty.
Set the constraint associated with the contingency.
Set the constraint associated with the contingency. Removes previous constraints associated with the contingency. By default, the contingency is empty.
Set the log constraint associated with the contingency.
Set the log constraint associated with the contingency. Removes previous constraints associated with the contingency. By default, the contingency is empty.
Set the randomness of this element.
Set the randomness of this element.
Will generate its value using the new randomness and propagate the effects to elements that depend on it without changing their randomness.
A string that is the element's name, if it has a non-empty one, otherwise the result of the element's toString
The universe in which the element is defined.
Removes conditions on the element and allows different values of the element to be generated
Allows different values of the element to be generated.
The current value of the element.
An Element is the core component of a probabilistic model. Elements can be understood as defining a probabilistic process. Elements are parameterized by the type of Value the process produces.
Each Element is a mix of a random component and a deterministic component. The random component has type Randomness. The generateRandomness method generates the Randomness according to a probability distribution. The generateValue method is a deterministic function that generates the output Value of the Element from the Randomness. Thus, Elements can be understood as defining a generative process in which first the Randomness is generated and then the output Value is generated given the Randomness.
Elements also have a current outcome, represented by the value field. Naturally, the generateValue function can refer to the current value of related Elements. However, generateValue is not allowed to call generateValue on another Element. We use the notation generateValue(r | w) to denote the value it produces given randomness r when the current value of related Elements is w.
Elements can have hard conditions and soft constraints. A condition is a predicate on Values that must be satisfied by the output of the Element. Values that violate the condition have probability zero. A constraint is a function that maps Values to Doubles. The probability of a Value is multiplied by the constraint, and then normalized. Conditions and constraints can be contingent on other elements taking on particular values. Ordinarily, these contingencies will not be specified by the user, but automatically by other Figaro code. In particular, specifying named evidence on a reference can result in contingencies.
Thus, an Element represents a conditional probability distribution over Values given the current values w of related Elements. The probability of an outcome v is defined by:
P(v | w) is proportional to (\sum_{r: generateValue(r | w) = v} P(generateRandomness() = r) * constraint(v)) if condition(v); 0 otherwise
An element has a name and belongs to an element collection that is used to find the element the name.
Elements can be cacheable or non-cacheable, which determines what type of Chain will be created for them. If you create a new Element class that you want to be cached, you should declare it to implement the Cachable or IfArgsCachable traits.