uk.co.agena.minerva.util.nptgenerator
Class Function

java.lang.Object
  extended by uk.co.agena.minerva.util.nptgenerator.Function
Direct Known Subclasses:
Arithmetic, Beta, Binomial, ChiSquared, Comparative, Exponential, ExtremeValue, Gamma, Geometric, Hypergeometric, Logistic, LogNormal, NegativeBinomial, Normal, Poisson, Student, TNormal, Triangle, Uniform, Weibull

public abstract class Function
extends java.lang.Object


Field Summary
static java.lang.String ALLOWED_CHARACTERS
           
static java.lang.String displayName
           
static java.lang.String NEWLINE
           
static char TAB
           
static double[][] VARIANCE_MAP
           
static java.lang.Class[] WEIGHTED_FUNCTIONS
           
 
Constructor Summary
Function()
           
Function(ExtendedNode extendedNode, java.util.List parents, java.lang.String[] expressions, java.lang.String functionType)
           
 
Method Summary
static double[] calculateFunction(java.lang.String functionType, java.util.List stateInformation, java.lang.String[] functionParams, ExtendedNode extendedFunctionNode)
           
abstract  void calculateProbability(DataSet values)
          Override this method to do what the function requires.
static Function createFunction(java.lang.String functionType, ExtendedNode node, java.util.List parents, java.util.List functionParams)
           
 double evaluateExpressionAsDouble(DataSet values, int expressionIndex)
          Evaluates the expression at the supplied index.
 java.lang.Object evaluateExpressionAsObject(DataSet values, int expressionIndex)
          Evaluates the expression at the supplied index.
protected  void generateNPTForNodeWithoutSampling()
          This is used to create a single column NPT for a node which is asked to generate an NPT but doesn't have any parents.
abstract  java.lang.String getDisplayName()
          Shows the name of the Function subclass as it should be displayed in a GUI etc.
static uk.co.agena.minerva.util.nptgenerator.parserextension.WeightedFunction getDummyWeightedFunctionFromTrueName(java.lang.String trueName)
           
 double getMaximumValueReached()
           
 double getMinimumValueReached()
           
abstract  java.lang.String[] getParameterDisplayNames()
          Shows the name of the parameters of the Function subclass as they should be displayed in a GUI etc.
 double[] getSingleColumnNPT()
           
 boolean isForceSampling()
           
protected  boolean requiresSampling()
          We can check if this function needs sampling or not by taking each expression and testing to see if it contains the names of any of the parents of this node.
static void resetParserCache()
          Resets the cache of parsed expressions.
 void setForceSampling(boolean forceSampling)
           
protected  void setMaximumValueReached(double maximumValueReached)
           
protected  void setMinimumValueReached(double minimumValueReached)
           
 void setPossibleMaxOrMinVaule(double value)
          Given a value this function will test and assign it to the relative Max or Min Value attained for this function.
 java.lang.String toString()
          Default toString method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VARIANCE_MAP

public static final double[][] VARIANCE_MAP

NEWLINE

public static final java.lang.String NEWLINE

TAB

public static final char TAB
See Also:
Constant Field Values

displayName

public static java.lang.String displayName

ALLOWED_CHARACTERS

public static final java.lang.String ALLOWED_CHARACTERS

WEIGHTED_FUNCTIONS

public static final java.lang.Class[] WEIGHTED_FUNCTIONS
Constructor Detail

Function

public Function()

Function

public Function(ExtendedNode extendedNode,
                java.util.List parents,
                java.lang.String[] expressions,
                java.lang.String functionType)
         throws NPTGeneratorException,
                InconsistentEvidenceException
Throws:
NPTGeneratorException
InconsistentEvidenceException
Method Detail

resetParserCache

public static void resetParserCache()
Resets the cache of parsed expressions.


getDisplayName

public abstract java.lang.String getDisplayName()
Shows the name of the Function subclass as it should be displayed in a GUI etc.


getParameterDisplayNames

public abstract java.lang.String[] getParameterDisplayNames()
Shows the name of the parameters of the Function subclass as they should be displayed in a GUI etc.


calculateProbability

public abstract void calculateProbability(DataSet values)
                                   throws ExtendedBNException,
                                          NPTGeneratorInsufficientStateRangeException,
                                          NPTGeneratorException
Override this method to do what the function requires. Should calculate the probability for each state of this node (using the range of each state as the the upper and lower bound for the appropriate function. Then add this probability value to the value already present for the relevant state and the given rowMajorParentStateCombIndex.

Throws:
ExtendedBNException
NPTGeneratorInsufficientStateRangeException
NPTGeneratorException

evaluateExpressionAsDouble

public double evaluateExpressionAsDouble(DataSet values,
                                         int expressionIndex)
                                  throws NPTGeneratorException
Evaluates the expression at the supplied index. The supplied values are used to update any variables in the relevant parsers.

Parameters:
values - the values used for plugging into the expression
expressionIndex - the index of the expression that is to be evaluated
Returns:
the value of the expression represented as a double
Throws:
NPTGeneratorException

evaluateExpressionAsObject

public java.lang.Object evaluateExpressionAsObject(DataSet values,
                                                   int expressionIndex)
                                            throws NPTGeneratorException
Evaluates the expression at the supplied index. The supplied values are used to update any variables in the relevant parsers.

Parameters:
values - the values used for plugging into the expression
expressionIndex - the index of the expression that is to be evaluated
Returns:
the value of the expression represented as a double
Throws:
NPTGeneratorException

isForceSampling

public boolean isForceSampling()

setForceSampling

public void setForceSampling(boolean forceSampling)

generateNPTForNodeWithoutSampling

protected void generateNPTForNodeWithoutSampling()
                                          throws NPTGeneratorException
This is used to create a single column NPT for a node which is asked to generate an NPT but doesn't have any parents.

Throws:
NPTGeneratorException

getDummyWeightedFunctionFromTrueName

public static uk.co.agena.minerva.util.nptgenerator.parserextension.WeightedFunction getDummyWeightedFunctionFromTrueName(java.lang.String trueName)
                                                                                                                   throws java.lang.InstantiationException,
                                                                                                                          java.lang.IllegalAccessException
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

createFunction

public static Function createFunction(java.lang.String functionType,
                                      ExtendedNode node,
                                      java.util.List parents,
                                      java.util.List functionParams)
                               throws NPTGeneratorException,
                                      InconsistentEvidenceException
Throws:
NPTGeneratorException
InconsistentEvidenceException

calculateFunction

public static double[] calculateFunction(java.lang.String functionType,
                                         java.util.List stateInformation,
                                         java.lang.String[] functionParams,
                                         ExtendedNode extendedFunctionNode)
                                  throws NPTGeneratorException
Throws:
NPTGeneratorException

getSingleColumnNPT

public double[] getSingleColumnNPT()
Returns:

requiresSampling

protected boolean requiresSampling()
We can check if this function needs sampling or not by taking each expression and testing to see if it contains the names of any of the parents of this node.

Returns:

setPossibleMaxOrMinVaule

public void setPossibleMaxOrMinVaule(double value)
Given a value this function will test and assign it to the relative Max or Min Value attained for this function.

Parameters:
value -

getMaximumValueReached

public double getMaximumValueReached()
Returns:
Returns the maximumValueReached.

getMinimumValueReached

public double getMinimumValueReached()
Returns:
Returns the minimumValueReached.

setMaximumValueReached

protected void setMaximumValueReached(double maximumValueReached)
Parameters:
maximumValueReached - The maximumValueReached to set.

setMinimumValueReached

protected void setMinimumValueReached(double minimumValueReached)
Parameters:
minimumValueReached - The minimumValueReached to set.

toString

public java.lang.String toString()
Default toString method. Subclasses should implement their own specific version.

Overrides:
toString in class java.lang.Object


Copyright © 2006 Agena Ltd. All Rights Reserved.