blog
Class DerivedVar

java.lang.Object
  extended by blog.DerivedVar
All Implemented Interfaces:
BayesNetVar

public class DerivedVar
extends java.lang.Object
implements BayesNetVar

A random variable whose value is a deterministic function of some basic variables. In this default implementation, the DerivedVar's value is given by some ArgSpec.


Field Summary
protected  ArgSpec argSpec
           
 
Constructor Summary
DerivedVar(ArgSpec argSpec)
          Creates a new DerivedVar whose value is given by argSpec.
 
Method Summary
 void ensureDetAndSupported(InstantiatingEvalContext instantiator)
          Ensures that the partial world underlying the given InstantiatingEvalContext is complete enough to determine the value of this variable and to determine its probability distribution conditional on its parents.
 ArgSpec getArgSpec()
          Returns the ArgSpec that determines this variable's value.
 BasicVar getFirstUninstParent(PartialWorld w)
          Returns the first parent of this variable that is uninstantiated in the given partial world.
 java.util.Set getParents(PartialWorld w)
          Returns the set of parents of this variable in the given partial world.
 java.lang.Object getValue(EvalContext context)
          Returns the value of this random variable in the given context.
 java.lang.Object getValue(PartialWorld w)
          Returns the value of this random variable in the given world.
 boolean isDetermined(PartialWorld w)
          Returns true if the given world is complete enough to determine the value of this random variable.
 Timestep timestep()
          Returns the timestep that this variable is associated with, or null if it is atemporal.
 java.lang.String toString()
          Returns the string representation of this derived variable's ArgSpec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

argSpec

protected ArgSpec argSpec
Constructor Detail

DerivedVar

public DerivedVar(ArgSpec argSpec)
Creates a new DerivedVar whose value is given by argSpec.

Method Detail

getArgSpec

public ArgSpec getArgSpec()
Returns the ArgSpec that determines this variable's value.


isDetermined

public boolean isDetermined(PartialWorld w)
Description copied from interface: BayesNetVar
Returns true if the given world is complete enough to determine the value of this random variable.

Specified by:
isDetermined in interface BayesNetVar

getValue

public java.lang.Object getValue(PartialWorld w)
Returns the value of this random variable in the given world.

Specified by:
getValue in interface BayesNetVar

getValue

public java.lang.Object getValue(EvalContext context)
Returns the value of this random variable in the given context.


getParents

public java.util.Set getParents(PartialWorld w)
Description copied from interface: BayesNetVar
Returns the set of parents of this variable in the given partial world. The parents are those random variables which, if they changed, could change the probability of this variable having a given value. This method yields a fatal error if the partial world is not complete enough to determine this variable's parents.

Specified by:
getParents in interface BayesNetVar
Returns:
Set of BayesNetVar

getFirstUninstParent

public BasicVar getFirstUninstParent(PartialWorld w)
Description copied from interface: BayesNetVar
Returns the first parent of this variable that is uninstantiated in the given partial world. This method uses a decision tree view of the variable's CPD; it walks down the tree until it reaches a node corresponding to an uninstantiated variable. If all of this variable's active parents in the given partial world are instantiated, then this method returns null.

Specified by:
getFirstUninstParent in interface BayesNetVar

ensureDetAndSupported

public void ensureDetAndSupported(InstantiatingEvalContext instantiator)
Description copied from interface: BayesNetVar
Ensures that the partial world underlying the given InstantiatingEvalContext is complete enough to determine the value of this variable and to determine its probability distribution conditional on its parents.

Specified by:
ensureDetAndSupported in interface BayesNetVar

timestep

public Timestep timestep()
Description copied from interface: BayesNetVar
Returns the timestep that this variable is associated with, or null if it is atemporal.

Specified by:
timestep in interface BayesNetVar

toString

public java.lang.String toString()
Returns the string representation of this derived variable's ArgSpec.

Overrides:
toString in class java.lang.Object