java.lang.Object
es.upm.fi.cig.multictbnc.nodes.AbstractNode
es.upm.fi.cig.multictbnc.nodes.DiscreteStateNode
es.upm.fi.cig.multictbnc.nodes.CPTNode
- All Implemented Interfaces:
Node
Extends the DiscreteNode class to store a CPT and the sufficient statistics for a BN.
-
Constructor Summary
ConstructorDescriptionConstructor that receives aCPTNode
and clones it.Constructor that receives the name of the variable and its possible states.Constructor that receives the name of the variable, a list of strings with its possible states and if it is a class variable. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if the parameters of the node were estimated.double
Returns the local log-likelihood for the node.double
getCP
(int idxStateParents, int idxStateNode) Returns the conditional probability of a state of the node given the state of the parents.double[][]
getCPT()
Returns the conditional probability table (CPT) of the node.Returns sufficient statistics of the node.sampleState
(double percentageNoisyStates) Samples the state of the node given evidence using forward sampling.void
setCPT
(double[][] CPT) Establishes the CPT of the node.void
setSufficientStatistics
(SufficientStatistics sufficientStatistics) Establishes the sufficient statistics of a CPT node.toString()
Methods inherited from class es.upm.fi.cig.multictbnc.nodes.DiscreteStateNode
clearParentAndChildrenSets, getIdxState, getIdxStateParents, getIdxStateParents, getNumStates, getNumStatesParents, getState, getStates, removeParent, setParent, setState, setState, setStateParents
Methods inherited from class es.upm.fi.cig.multictbnc.nodes.AbstractNode
equals, getChildren, getName, getNumParents, getParents, hasChildren, hasClassVariableAsParent, hasClassVariableAsSpouse, hashCode, hasParents, isClassVariable, isClassVariable, isDisconnected, isInMarkovBlanketClassVariable, removeAllEdges, removeChild, removeChildren, removeParents, setChild
-
Constructor Details
-
CPTNode
Constructor that receives the name of the variable and its possible states.- Parameters:
name
- name of the nodestates
- list of strings representing the states that the variable related to the node can take
-
CPTNode
Constructor that receives the name of the variable, a list of strings with its possible states and if it is a class variable.- Parameters:
name
- name of the nodestates
- list of strings representing the states that the variable related to the node can takeisClassVariable
- true if the node represent a class variable, false otherwise
-
CPTNode
Constructor that receives aCPTNode
and clones it. Everything is cloned except the sufficient statistics.- Parameters:
node
- node to clone
-
-
Method Details
-
getCPT
public double[][] getCPT()Returns the conditional probability table (CPT) of the node.- Returns:
- the conditional probability table of the node
-
setCPT
public void setCPT(double[][] CPT) Establishes the CPT of the node.- Parameters:
CPT
- CPT of the node
-
getCP
public double getCP(int idxStateParents, int idxStateNode) Returns the conditional probability of a state of the node given the state of the parents.- Parameters:
idxStateParents
- index of the parents' stateidxStateNode
- index of the node state- Returns:
- conditional probability of a state of the node given the state of the parent
-
getSufficientStatistics
Returns sufficient statistics of the node.- Returns:
- sufficient statistics
-
setSufficientStatistics
Establishes the sufficient statistics of a CPT node.- Parameters:
sufficientStatistics
- sufficient statistics of a CPT node
-
estimateLogLikelihood
public double estimateLogLikelihood()Description copied from interface:Node
Returns the local log-likelihood for the node.- Returns:
- local log-likelihood
-
sampleState
Samples the state of the node given evidence using forward sampling. First it is sampled from a uniform * distribution, then it is iterated over the state of the nodes and accumulated the probability of each of them. * Once this accumulated probability is more than the sampled value from the uniform distribution, the current * state under study is returned.- Parameters:
percentageNoisyStates
- value from 0 to 1 representing the probability of randomly sampling the state of the variable- Returns:
- sampled state of the node. Null is returned if the state could not be sampled
-
areParametersEstimated
public boolean areParametersEstimated()Description copied from interface:Node
Returns true if the parameters of the node were estimated.- Returns:
- true if the parameters of the node were estimated, false otherwise
-
toString
- Overrides:
toString
in classDiscreteStateNode
-