abstract class Element[T] extends AnyRef

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 Cacheable or IfArgsCacheable traits.

Linear Supertypes
AnyRef, Any
Known Subclasses
ValuesMaker, AtomicBeta, AtomicExponential, AtomicGamma, AtomicInverseGamma, AtomicNormal, AtomicUniform, NormalProposer, Aggregate, Apply, Apply1, Apply2, Apply3, Apply4, Apply5, ArrayParameter, Atomic, AtomicDist, AtomicFlip, AtomicSelect, Cacheable, CachingChain, Chain, CompoundDist, CompoundFlip, CompoundSelect, Constant, Continuous, Deterministic, Dist, DoubleParameter, Flip, HasDensity, IfArgsCacheable, Inject, MultiValuedReferenceElement, NonCachingChain, Parameter, Parameterized, ParameterizedFlip, ParameterizedSelect, ReferenceElement, Select, SingleParameterized, SingleValuedReferenceElement, AtomicBeta, AtomicDirichlet, AtomicExponential, AtomicGamma, AtomicInverseGamma, AtomicMultivariateNormal, AtomicNormal, AtomicUniform, Beta, CompoundBeta, CompoundDirichlet, CompoundExponential, CompoundGamma, CompoundNormal, CompoundUniform, Dirichlet, Exponential, Gamma, GammaCompoundK, InverseGamma, KernelDensity, MultivariateCompoundNormal, MultivariateNormal, MultivariateNormalCompoundMean, Normal, NormalCompoundMean, NormalCompoundVariance, Uniform, AtomicBinomial, AtomicGeometric, AtomicPoisson, AtomicSwitchingFlip, AtomicUniform, BinomialFixedNumTrials, CompoundAtomic, CompoundBinomial, CompoundGeometric, CompoundSwitchingFlip, CompoundUniform, FromRange, OneShifter, ParameterizedBinomialFixedNumTrials, SwitchingFlip, MakeArray, And, BooleanOperator, CPD1, CPD2, CPD3, CPD4, CPD5, Eq, FastIf, FoldLeft, If, IntSelector, Neq, Or, RichCPD1, RichCPD2, RichCPD3, RichCPD4, RichCPD5, CachingDecision, Decision, NonCachingDecision, MakeList
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Element
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Element(name: Name[T], collection: ElementCollection)

    name

    The name of the element

    collection

    The element collection to which this element belongs

Type Members

  1. type Condition = (T) ⇒ Boolean

    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.

  2. type Constraint = (T) ⇒ Double

    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.

  3. abstract type Randomness

    The type of randomness content of the element.

  4. type Value = T

    The type of values over which the element is defined.

Abstract Value Members

  1. abstract def args: List[Element[_]]

    The arguments on which the element depends.

  2. abstract def generateRandomness(): Randomness

    Generate the randomness content.

  3. abstract def generateValue(rand: Randomness): Value

    Generate the value of the element deterministically given its randomness and the values of its arguments.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. def !==(that: Element[Value])(implicit universe: Universe): Neq[Value]

    The element that tests inequality of this element with another element.

  3. final def ##(): Int
    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def ===(that: Value)(implicit universe: Universe): Apply1[T, Boolean]

    The element that tests whether the value of this element is equal to a particular value.

  6. def ===(that: Element[Value])(implicit universe: Universe): Eq[Value]

    The element that tests equality of this element with another element.

  7. def activate(): Unit

    Activate the element in its universe.

  8. var active: Boolean

    Flag indicating whether the element is currently active in its universe.

  9. def addCondition(condition: Condition, contingency: Contingency = List()): Unit

    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.

  10. def addConstraint(constraint: Constraint, contingency: Contingency = List()): Unit

    Add a contingent constraint to the element.

    Add a contingent constraint to the element. By default, the contingency is empty.

  11. def addLogConstraint(constraint: Constraint, contingency: Contingency = List()): Unit

    Add a log contingent constraint to the element.

    Add a log contingent constraint to the element. By default, the contingency is empty.

  12. def addPragma(pragma: Pragma[Value]): Unit

    Add a pragma to the element.

  13. def allConditions: List[(Condition, Contingency)]

    All the conditions defined on this element.

  14. def allConstraints: List[(Constraint, Contingency)]

    The current soft constraints on the element.

  15. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  16. def clearContext(): Unit

    Clears all the temporary elements associated with this element (all elements created in it's context).

  17. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. val collection: ElementCollection
  19. def condition(value: Any): Boolean

    Tests whether all the element's contingent conditions are satisfied for the given value.

  20. def conditionSatisfied: Boolean

    Determines whether the condition on the element is satisfied by the current value.

  21. def constraint(value: Any): Double

    Gets the result of all the element's contingent constraints for the given value.

  22. def constraintValue: Double

    Determines the value of the constraint on the element applied to the current value.

  23. def context: List[Element[_]]

    The elements on which the existence of this element depends.

  24. def deactivate(): Unit

    Deactivate the element in its universe.

  25. def directContextContents: Set[Element[_]]

    Returns the set of elements directly created in the context of this element.

  26. def elementsIAmContingentOn: Set[Element[_]]

    Returns the elements that this element is contingent on.

    Returns the elements that this element is contingent on. These are elements that are required to have a certain value for a condition or constraint to be relevant to this element. The contingency is required because conditions and constraints can be applied to references that are uncertain. Every possible element that could be pointed to by a reference must be given the condition or constraint, but the condition or constraint only applies if the elements earlier in the reference have the required value.

    Figaro takes care of handling all this under the hood. However, some algorithms may need to know which elements an element is contingent on. For example, sampling algorithms may need to sample those other elements first. This method is supplied to support this use case.

  27. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  29. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  30. def flatMap[U](fn: (Value) ⇒ Element[U])(implicit name: Name[U], collection: ElementCollection): Element[U]
  31. final def generate(): Unit

    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.

  32. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  33. val hashCode: Int
  34. def intervene(v: Value): Unit
  35. def isCachable(): Boolean

    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.

  36. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  37. def isTemporary: Boolean

    Returns true if this element is temporary, that is, was created in the context of another element.

  38. def map[U](fn: (Value) ⇒ U)(implicit name: Name[U], collection: ElementCollection): Element[U]
  39. val name: Name[T]
  40. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  41. def nextRandomness(rand: Randomness): (Randomness, Double, Double)

    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.

  42. final def notify(): Unit
    Definition Classes
    AnyRef
  43. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  44. def observe(observation: Value): Unit

    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.

  45. def pragmas: List[Pragma[Value]]

    The pragmas attached to the element.

  46. var randomness: Randomness

    The current randomness content of the element.

  47. def removeConditions(contingency: Contingency = List()): Unit

    Remove all conditions associated with the given contingency.

    Remove all conditions associated with the given contingency. By default, the contingency is empty.

  48. def removeConstraint(constraint: Constraint, contingency: Contingency = List()): Unit
    Attributes
    protected
  49. def removeConstraints(contingency: Contingency = List()): Unit

    Remove all constraints associated with the given contingency.

    Remove all constraints associated with the given contingency. By default, the contingency is empty.

  50. def removePragma(pragma: Pragma[Value]): Unit

    Remove a pragma from the element.

  51. def score(oldValue: Value, newValue: Value): Double

    Compute the constraints on the new value divided by the constraints on the old value.

  52. def set(newValue: Value): Unit

    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.

  53. def setCondition(newCondition: Condition, contingency: Contingency = List()): Unit

    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.

  54. def setConstraint(newConstraint: Constraint, contingency: Contingency = List()): Unit

    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.

  55. def setLogConstraint(newConstraint: Constraint, contingency: Contingency = List()): Unit

    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.

  56. def setRandomness(newRandomness: Randomness): Unit

    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.

  57. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  58. def toNameString: String

    A string that is the element's name, if it has a non-empty one, otherwise the result of the element's toString.

  59. def toString(): String
    Definition Classes
    AnyRef → Any
  60. def unintervene(): Unit
  61. val universe: Universe

    The universe in which the element is defined.

  62. def unobserve(): Unit

    Removes conditions on the element and allows different values of the element to be generated.

  63. def unset(): Unit

    Allows different values of the element to be generated.

  64. var value: Value

    The current value of the element.

  65. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  66. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  67. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped