uk.co.agena.minerva.model.extendedbn
Class DiscreteRealEN

java.lang.Object
  extended by uk.co.agena.minerva.model.extendedbn.ExtendedNode
      extended by uk.co.agena.minerva.model.extendedbn.NumericalEN
          extended by uk.co.agena.minerva.model.extendedbn.DiscreteRealEN
All Implemented Interfaces:
java.lang.Comparable, java.util.EventListener, ExtendedNodeListener, ExtendedStateListener, Identifiable, Nameable, Writable

public class DiscreteRealEN
extends NumericalEN

A DiscreteRealEN is a node whose states represent real numbers that are in no particular order e.g. -2.0, 4.5, 0, 1.8


Field Summary
protected static java.lang.String[][] defaultStateNames
           
 
Fields inherited from class uk.co.agena.minerva.model.extendedbn.ExtendedNode
actOnMarginalsChangedEvent, answerable, connBn, connectableInputNode, connectableOutputNode, connNodeId, CONTINUOUS_INTERVAL_E_N, CURRENT_FUNCTION_STRING, currentNodeFunction, currentParentModelNodeAltId, currentPartitionedModelNodeFunctions, currentPartitionedParentModelNodeAltIds, currentPartitionedParentModelNodes, DEFAULT_FUNCTION_STRING, defaultNodeFunction, defaultParentModelNodeAltId, defaultPartitionedModelNodeFunctions, defaultPartitionedParentModelNodeAltIds, defaultPartitionedParentModelNodes, DELTA, DISCRETE_REAL_E_N, EDITABLE_NODE_FUNCTION, EDITABLE_NPT, EDITABLE_PARENT_STATE_FUNCTIONS, extendedStates, functionMode, id, inputNodeReceivedMarginals, LABELLED_E_N, name, nptReCalcRequired, nptSynchronisedWithFormula, NUMERICAL_E_N, PROBS_NOT_EDITABLE, reportable, supportedFunctionTypes, targetValue, targetValuePresent, version, visible
 
Fields inherited from interface uk.co.agena.minerva.util.model.Writable
FIELD_SEPARATOR
 
Constructor Summary
DiscreteRealEN()
          Default constructor.
DiscreteRealEN(NameDescription name, uk.co.agena.minerva.model.corebn.CoreBN connBn)
          Constructs a DiscreteRealEN with the specified name and connected Core BN.
DiscreteRealEN(NameDescription name, java.lang.String connNodeId, uk.co.agena.minerva.model.corebn.CoreBN connBn)
          Constructs a DiscreteRealEN with the specified name, connected node ID and connected BN.
 
Method Summary
 void configureDefaultExtendedStates()
          Sets up a default list of ExtendedStates for this node based on the default state names for this class.
protected  DataPoint createDataPointFromExtendedState(ExtendedState es, double value)
          Creates a DataPoint for the supplied ExtendedState that represents the marginal probability associated with the ExtendedState.
 DataSet createDataSetForExtendedStates()
          Create a DatsSet from the Extended States of this node.
 DataSet createDataSetFromNumericValue(double value, NameDescription name)
          Takes the supplied value and creates a DataSet of evidence.
 java.util.List createExtendedStates(DataSet ds)
          Takes the supplied DataSet and uses it to generate a List of ExtendedStates which are then returned.
 ExtendedState createNewExtendedState(int index)
          Creates a new ExtendedState, all the way to the core.
 void extendedNodeAttributeChanged(ExtendedNodeEvent ene, int attribute)
          Called when selected attributes of the node are changed.
static java.lang.String[][] getDefaultStateNames()
           
 java.lang.Object getSamplesForState(int index, boolean boundsOnly)
          Just returns the single numerical value as the only sample for the supplied state.
 double mean()
          Calculates the mean of the marginals for this ExtendedNode.
 double median()
          Calculates the median of the marginals for this ExtendedNode.
 double percentile(double perc)
          Calculates the specified percentile of the marginals for this ExtendedNode.
 java.util.List replaceState(int index, int numDivisions)
          Takes the state at the specified index and replaces it with the required number of new states.
 double standardDeviation()
          Calculates the standard deviation of the marginals for this ExtendedNode.
 double variance()
          Calculates the variance of the marginals for this ExtendedNode.
 
Methods inherited from class uk.co.agena.minerva.model.extendedbn.NumericalEN
fillArraysUsingAbsolutes, fillArraysUsingIntervals, getDisceteValues
 
Methods inherited from class uk.co.agena.minerva.model.extendedbn.ExtendedNode
addChild, addExpressionVariable, addExtendedNodeListener, addExtendedState, addExtendedState, addExtendedStates, addParent, cloneTypeSpecific, compareTo, constructExtraFieldString, containsFunctionOfType, containsOnlyStatisticalFunctions, copy, cropFunctions, enterDistributionOfEvidence, enterDistributionOfEvidence, enterHardEvidence, enterHardEvidence, extendedNodeConnBNNotFound, extendedNodeConnNodeIdChanged, extendedNodeInconsistentEvidenceEntered, extendedNodeMarginalsChanged, extendedNodeNameDescriptionChanged, extendedNodeStateNameChanged, extendedNodeStatesReplaced, extendedNodeVariableAdded, extendedNodeVariableRemoved, extendedNodeVisibleAttributeChanged, extendedStateAdded, extendedStateNameDescriptionChanged, extendedStateRemoved, fireMarginalsChangedEvent, getActOnMarginalsChangedEvent, getAnswerable, getConcreteNodeName, getConcreteNodeType, getConcreteNodeTypeNames, getConnBn, getConnNodeId, getCoreBNNodeEquivalents, getCurrentNodeFunction, getCurrentParentModelNodeAltId, getCurrentPartitionedModelNodeFunctions, getCurrentPartitionedParentModelNodeAltIds, getCurrentPartitionedParentModelNodes, getDefaultNodeFunction, getDefaultParentModelNodeAltId, getDefaultPartitionedModelNodeFunctions, getDefaultPartitionedParentModelNodeAltIds, getDefaultPartitionedParentModelNodes, getExpression, getExpressionVariables, getExtendedState, getExtendedStateAtIndex, getExtendedStates, getExtendedStateShortNames, getExtendedStateWithName, getExtendedStateWithShortDesc, getFunctionMode, getHardEvidence, getId, getInputNodeRecivedMarginalsAsEvidenceDS, getLastSavedPriorIndex, getMarginals, getName, getNextExtendedStateId, getNodeType, getNotes, getNPT, getNPTPopulationMethodAsString, getNPTSize, getNumberOfStateCombsForModelNodes, getPartitionedExpressionModelNodes, getPartitionedExpressions, getReportable, getRowMajorNPT, getSavedPriors, getScaledTargetValue, getSuitableMessagePassingNodes, getSupportedFunctionTypes, getTargetValue, getTargetValueAsString, getTargetValueRange, getTargetValueRangeAsString, getTotalNumberOfExtendedFunctions, getVersion, getVisible, hasParents, isChangeStatesOnInputNodeIfRequired, isConnectableInputNode, isConnectableOutputNode, isInputNodeReceivedMarginals, isInputNodeRecivedMarginalsAsEvidence, isNptReCalcRequired, isNptSynchronisedWithFormula, isTargetValuePresent, isTemporaryNodeOrderFlag, mode, nodeChanged, processExtraFields, read, recalculateConnStateIndices, removeAllFurtherSavedPriors, removeExpressionVariable, removeExtendedNodeListener, removeExtendedState, replicateNodeStates, revert2savedPrior, savePrior, setActOnMarginalsChangedEvent, setAnswerable, setChangeStatesOnInputNodeIfRequired, setConnBn, setConnectableInputNode, setConnectableOutputNode, setConnNodeId, setCurrentNodeFunction, setCurrentParentModelNodeAltId, setCurrentPartitionedModelNodeFunctions, setCurrentPartitionedParentModelNodeAltIds, setCurrentPartitionedParentModelNodes, setDefaultNodeFunction, setDefaultParentModelNodeAltId, setDefaultPartitionedModelNodeFunctions, setDefaultPartitionedParentModelNodeAltIds, setDefaultPartitionedParentModelNodes, setExpression, setExpressionVariables, setExtendedStates, setExtendedStates, setFunctionMode, setId, setInputNodeReceivedMarginals, setInputNodeRecivedMarginalsAsEvidence, setInputNodeRecivedMarginalsAsEvidenceDS, setName, setNotes, setNPT, setNPT, setNPT, setNPTForSingleModelParentNode, setNptReCalcRequired, setNptSynchronisedWithFormula, setPartitionedExpressionModelNodes, setPartitionedExpressions, setReportable, setSavedPriors, setTargetValue, setTargetValueFromString, setTargetValuePresent, setTemporaryNodeOrderFlag, setupActionForMarginalsChangedEvent, setVersion, setVisible, storeFunctionsCorrectly, toString, updateConnNodeId, updateExpressionVariable, updateFunctionsParentConnNodeId, updateFunctionType, usedInCurrentExpression, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultStateNames

protected static java.lang.String[][] defaultStateNames
Constructor Detail

DiscreteRealEN

public DiscreteRealEN()
Default constructor.


DiscreteRealEN

public DiscreteRealEN(NameDescription name,
                      uk.co.agena.minerva.model.corebn.CoreBN connBn)
               throws ExtendedBNException
Constructs a DiscreteRealEN with the specified name and connected Core BN.

Parameters:
name - the name of the DiscreteRealEN
connBn - a reference to the underlying BN
Throws:
ExtendedNodeCreationException - if there is a problem creating the node
ExtendedBNException

DiscreteRealEN

public DiscreteRealEN(NameDescription name,
                      java.lang.String connNodeId,
                      uk.co.agena.minerva.model.corebn.CoreBN connBn)
               throws ExtendedBNException
Constructs a DiscreteRealEN with the specified name, connected node ID and connected BN. It also initialises the ExtendedStates with numerical values and Ranges. The numerical value will be the midpoint of the Range. If the Range has infinity at either end, then the midpoint is calculated as the scaled value, as specified in scaleInfinities().

Parameters:
name - the name of the NumericalEN
connNodeId - the ID of the connected node in the underlying BN.
connBn - a reference to the underlying CoreBN
Throws:
ExtendedBNException - if there is a problem creating the node
Method Detail

getDefaultStateNames

public static java.lang.String[][] getDefaultStateNames()

configureDefaultExtendedStates

public void configureDefaultExtendedStates()
                                    throws ExtendedStateException
Sets up a default list of ExtendedStates for this node based on the default state names for this class.

Specified by:
configureDefaultExtendedStates in class ExtendedNode
Throws:
ExtendedStateException

createDataSetFromNumericValue

public DataSet createDataSetFromNumericValue(double value,
                                             NameDescription name)
                                      throws ExtendedBNException
Takes the supplied value and creates a DataSet of evidence. If the entered value falls exactly in the middle of a Range, the DataSet will contain a single DataPoint with a probability of 1.0 for that Range. In all other cases, the DataSet will contain 2 DataPoints: one corresponding to the Range that the value falls into and one corresponding to the adjacent Range (on whichever side of the midpoint the value falls). The probability values of each DataPoint reflect the distance of the value from the midpoint.

Specified by:
createDataSetFromNumericValue in class NumericalEN
Parameters:
value - the value entered as an observation
Returns:
the created DataSetGrouping
Throws:
ExtendedBNException - if there is a problem creating the DataSet

createDataPointFromExtendedState

protected DataPoint createDataPointFromExtendedState(ExtendedState es,
                                                     double value)
                                              throws ExtendedBNException
Creates a DataPoint for the supplied ExtendedState that represents the marginal probability associated with the ExtendedState. This is used when getMarginals() is called on the node.

Overrides:
createDataPointFromExtendedState in class ExtendedNode
Parameters:
es - the ExtendedState that the DataPoint will represent
value - the marginal probability value currently associated with the ExtendedState
Returns:
a DataPoint encapsulating the marginal probability and state information.
Throws:
ExtendedBNException - if there is a problem creating the DataPoint (only thrown in selected subclasses)

createExtendedStates

public java.util.List createExtendedStates(DataSet ds)
                                    throws ExtendedStateNumberingException,
                                           ExtendedStateException
Description copied from class: ExtendedNode
Takes the supplied DataSet and uses it to generate a List of ExtendedStates which are then returned. Each type of node can potentially use the DataSet to generate states in a different. Implementations are provided lower down in the hierarchy.

Specified by:
createExtendedStates in class ExtendedNode
Parameters:
ds - the DataSet used for creating the ExtendedStates
Returns:
a List of created ExtendedStates
Throws:
ExtendedStateNumberingException
ExtendedStateException

createDataSetForExtendedStates

public DataSet createDataSetForExtendedStates()
                                       throws ExtendedStateException
Create a DatsSet from the Extended States of this node.

Specified by:
createDataSetForExtendedStates in class ExtendedNode
Returns:
Throws:
ExtendedStateException

extendedNodeAttributeChanged

public void extendedNodeAttributeChanged(ExtendedNodeEvent ene,
                                         int attribute)
Description copied from class: ExtendedNode
Called when selected attributes of the node are changed. The Int value in the second arguement defines what attribute it was that changed, the constant value for which are available on the ExtendedNodeEvent class

Specified by:
extendedNodeAttributeChanged in interface ExtendedNodeListener
Overrides:
extendedNodeAttributeChanged in class ExtendedNode

replaceState

public java.util.List replaceState(int index,
                                   int numDivisions)
                            throws ExtendedStateException,
                                   ExtendedNodeMethodNotSupportedException
Takes the state at the specified index and replaces it with the required number of new states. NOTE: No implementation supported for this type of node.

Specified by:
replaceState in class ExtendedNode
Parameters:
index - the index of the state to split
numDivisions - the number of divisions it should be split into
Returns:
a List of the ExtendedStates that were created as part of the process
Throws:
ExtendedStateException
ExtendedNodeMethodNotSupportedException

createNewExtendedState

public ExtendedState createNewExtendedState(int index)
                                     throws ExtendedNodeMethodNotSupportedException,
                                            ExtendedBNException
Description copied from class: ExtendedNode
Creates a new ExtendedState, all the way to the core. It will add the state at the index specified. Give a -1 value if you wish the state to be added to the end of the list of existing states.

Specified by:
createNewExtendedState in class ExtendedNode
Returns:
Throws:
ExtendedBNException
ExtendedNodeMethodNotSupportedException

getSamplesForState

public java.lang.Object getSamplesForState(int index,
                                           boolean boundsOnly)
                                    throws ExtendedStateException
Just returns the single numerical value as the only sample for the supplied state.

Specified by:
getSamplesForState in class ExtendedNode
Parameters:
index - the index of the state to sample
boundsOnly - TODO
Returns:
an array containing one sample i.e. the numerical value of the state in question
Throws:
ExtendedStateNotFoundException - if there is no state at the supplied index
ExtendedStateException

mean

public double mean()
            throws ExtendedBNException
Description copied from class: NumericalEN
Calculates the mean of the marginals for this ExtendedNode.

Overrides:
mean in class NumericalEN
Returns:
the mean value
Throws:
ExtendedBNException - if there is a problem calculating the mean

median

public double median()
              throws ExtendedBNException
Description copied from class: NumericalEN
Calculates the median of the marginals for this ExtendedNode.

Overrides:
median in class NumericalEN
Returns:
the median value
Throws:
ExtendedBNException - if there is a problem calculating the median

percentile

public double percentile(double perc)
                  throws ExtendedBNException
Description copied from class: NumericalEN
Calculates the specified percentile of the marginals for this ExtendedNode.

Overrides:
percentile in class NumericalEN
Parameters:
perc - the required percentile
Returns:
the percentile value
Throws:
ExtendedBNException - if there is a problem calculating the percentile

standardDeviation

public double standardDeviation()
                         throws ExtendedBNException
Description copied from class: NumericalEN
Calculates the standard deviation of the marginals for this ExtendedNode.

Overrides:
standardDeviation in class NumericalEN
Returns:
the standard deviation value
Throws:
ExtendedBNException - if there is a problem calculating the standard deviation

variance

public double variance()
                throws ExtendedBNException
Description copied from class: NumericalEN
Calculates the variance of the marginals for this ExtendedNode.

Overrides:
variance in class NumericalEN
Returns:
the variance value
Throws:
ExtendedBNException - if there is a problem calculating the variance


Copyright © 2006 Agena Ltd. All Rights Reserved.