Module es.upm.fi.cig.multictbnc
Class CTBNSufficientStatistics
java.lang.Object
es.upm.fi.cig.multictbnc.learning.parameters.ctbn.CTBNSufficientStatistics
- All Implemented Interfaces:
SufficientStatistics
Computes and stores the sufficient statistics of a discrete CTBN node. The sufficient statistics are:
(1) Mxy: number of times a variable transitions from a certain state to another one while its parents take a certain instantiation.
(2) Mx: number of times a variable leaves a certain state (for any other state) while its parents take a certain instantiation.
(3) Tx: time that a variable stays in a certain state while its parents take a certain instantiation.
-
Constructor Summary
ConstructorDescriptionCTBNSufficientStatistics
(double mHP, double tHP) Receives the hyperparameters of the Dirichlet prior distribution over the parameters that are necessary for Bayesian estimation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
computeSufficientStatistics
(DiscreteStateNode node, Dataset dataset) Computes the sufficient statistics of a CTBN node.double[][]
getMx()
Returns the sufficient statistic with the number of times the variable leaves every state (i.e., the state changes) while its parents have certain values.double
Returns the value of the hyperparameter with the number of 'imaginary' transitions that occurred from a certain state before seeing the data.double[][][]
getMxy()
Returns the sufficient statistic with the number of times the variable transition from a certain state to another while its parents have certain valuesdouble
Returns the value of the hyperparameter with the number of 'imaginary' transitions that occurred from a certain state to another before seeing the data.double[][]
getTx()
Returns the sufficient statistic with the time that the variable stays in every state, while its parents take different values.double
Returns the value of the hyperparameter with the 'imaginary' time that was spent in a certain state before seeing the data.protected void
Initialises the structures to store the sufficient statistics of the node.protected void
updateMx
(int stateParents, int fromState, double numOccurrences) Updates the number of occurrences where the node transitions from a certain state to any other state given an instantiation of its parents.protected void
updateMxy
(int stateParents, int fromState, int toState, double numOccurrences) Updates the number of occurrences where the node transitions from a certain state to another given an instantiation of its parents.protected void
updateSufficientStatistics
(Sequence sequence, int idxFromState, int idxtoState, int idxStateParents, int idxObservation) Update the values of the sufficient statistics.
-
Constructor Details
-
CTBNSufficientStatistics
public CTBNSufficientStatistics(double mHP, double tHP) Receives the hyperparameters of the Dirichlet prior distribution over the parameters that are necessary for Bayesian estimation.- Parameters:
mHP
- number of times a variable transitions from a certain state (hyperparameter)tHP
- time that a variable stays in a certain state (hyperparameter)
-
-
Method Details
-
getMx
public double[][] getMx()Returns the sufficient statistic with the number of times the variable leaves every state (i.e., the state changes) while its parents have certain values.- Returns:
- number of times the variable leaves every state
-
getMxHyperparameter
public double getMxHyperparameter()Returns the value of the hyperparameter with the number of 'imaginary' transitions that occurred from a certain state before seeing the data.- Returns:
- hyperparameter with the number of 'imaginary' transitions that occurred from a certain state
-
getMxy
public double[][][] getMxy()Returns the sufficient statistic with the number of times the variable transition from a certain state to another while its parents have certain values- Returns:
- number of occurrences of every transition
-
getMxyHyperparameter
public double getMxyHyperparameter()Returns the value of the hyperparameter with the number of 'imaginary' transitions that occurred from a certain state to another before seeing the data.- Returns:
- hyperparameter with the number of 'imaginary' transitions that occurred from a certain state to another
-
getTx
public double[][] getTx()Returns the sufficient statistic with the time that the variable stays in every state, while its parents take different values.- Returns:
- time that the variable stay for every state
-
getTxHyperparameter
public double getTxHyperparameter()Returns the value of the hyperparameter with the 'imaginary' time that was spent in a certain state before seeing the data.- Returns:
- hyperparameter with the 'imaginary' time that was spent in a certain state
-
computeSufficientStatistics
Computes the sufficient statistics of a CTBN node.- Specified by:
computeSufficientStatistics
in interfaceSufficientStatistics
- Parameters:
dataset
- dataset from which sufficient statistics are extractednode
- node whose sufficient statistics are computed
-
initialiseSufficientStatistics
Initialises the structures to store the sufficient statistics of the node. In the case of Bayesian estimation, the imaginary counts are defined based on the number of states of the node and its parents, so the total number of imaginary samples is not influenced by the cardinality of those nodes.- Parameters:
node
- node
-
updateMx
protected void updateMx(int stateParents, int fromState, double numOccurrences) throws NeverSeenStateException Updates the number of occurrences where the node transitions from a certain state to any other state given an instantiation of its parents.- Parameters:
stateParents
- index of the state of the node's parentsfromState
- index of the current statenumOccurrences
- number of occurrences- Throws:
NeverSeenStateException
- thrown if new node's states appeared after the initialisation of the sufficient statistics
-
updateMxy
protected void updateMxy(int stateParents, int fromState, int toState, double numOccurrences) throws NeverSeenStateException Updates the number of occurrences where the node transitions from a certain state to another given an instantiation of its parents.- Parameters:
stateParents
- index of the state of the node's parentsfromState
- index of the state from which the transition startstoState
- index of the state to which the transition endsnumOccurrences
- number of times this transition occurs- Throws:
NeverSeenStateException
- thrown if new node's states appeared after the initialisation of the sufficient statistics
-
updateSufficientStatistics
protected void updateSufficientStatistics(Sequence sequence, int idxFromState, int idxtoState, int idxStateParents, int idxObservation) throws NeverSeenStateException Update the values of the sufficient statistics.- Parameters:
sequence
- sequence analysed when updating the sufficient statisticsidxFromState
- index of the state from which the transition used to update the sufficient statistics startsidxtoState
- index of the state to which the transition used to update the sufficient statistics endsidxStateParents
- index of the state the node's parents had when the transition occurred.idxObservation
- index of the observation where the transition ends- Throws:
NeverSeenStateException
- thrown if new node's states appeared after the initialisation of the sufficient statistics
-