de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions
Interface Transition

All Superinterfaces:
Cloneable, Storable
All Known Subinterfaces:
DifferentiableTransition, SamplingTransition, TrainableAndDifferentiableTransition, TrainableTransition, TransitionWithSufficientStatistic
All Known Implementing Classes:
BasicHigherOrderTransition, HigherOrderTransition

public interface Transition
extends Cloneable, Storable

This interface declares the methods of the transition used in a hidden Markov model. The interface declares the method getLogScoreFor(int, int, int, Sequence, int), which surprisingly has two additional parameter, namely the actual position and the sequence. These additional parameters allow to switch between different transition matrices. For more details, we refer, for instance, to ReferenceBasedTransitionElement.

Author:
Jan Grau, Jens Keilwagen, Michael Scharfe
See Also:
AbstractHMM

Method Summary
 Transition clone()
          This method returns a deep clone of the current instance.
 void fillTransitionInformation(int layer, int index, int childIdx, int[] container)
          This method fills all relevant information for a specific edge in a given container.
 int getChildIdx(int layer, int index, int state)
          This method returns the child index of the state, if this state is no child of the context -1 is returned
 String getGraphizNetworkRepresentation(NumberFormat nf, String arrowOption, boolean graphical)
          This method returns a String representation of the structure that can be used in Graphviz to create an image.
 int getLastContextState(int layer, int index)
          The method returns the index of the state of the context, if there is no context -1 is returned.
 double getLogPriorTerm()
          Returns a value that is proportional to the log of the prior.
 double getLogScoreFor(int layer, int index, int childIdx, Sequence sequence, int sequencePosition)
          This method returns the logarithm of the score for the transition.
 int getMaximalInDegree()
          This method returns the maximal out degree of any context used in this transition instance.
 int getMaximalMarkovOrder()
          This method returns the maximal used Markov order.
 int getMaximalNumberOfChildren()
          This method returns the maximal number of children for any context used in this transition instance.
 int getNumberOfChildren(int layer, int index)
          This method returns the number of children states for given index, i.e.
 int getNumberOfIndexes(int layer)
          This method computes the number of different indexes for a given layer of the matrix.
 int getNumberOfStates()
          This method returns the number of states underlying this transition instance.
 boolean hasAnySelfTransitions()
          This method answers the question whether the instance models any self transitions.
 void initializeRandomly()
          This method randomly initializes the parameters of the transition.
 boolean[] isAbsoring()
          This method returns for each state whether it is absorbing or not.
 void setParameters(Transition t)
          Set values of parameters of the instance to the value of the parameters of the given instance.
 String toString(String[] stateNames, NumberFormat nf)
          This method returns a String representation of the Transition using the given names of the states.
 
Methods inherited from interface de.jstacs.Storable
toXML
 

Method Detail

clone

Transition clone()
                 throws CloneNotSupportedException
This method returns a deep clone of the current instance.

Returns:
a deep clone of the current instance.
Throws:
CloneNotSupportedException - if the instance could not be cloned

getNumberOfChildren

int getNumberOfChildren(int layer,
                        int index)
This method returns the number of children states for given index, i.e. context, and a given layer of the matrix.

Parameters:
layer - the layer of the matrix
index - the index encoding the context
Returns:
the number of children states

getMaximalMarkovOrder

int getMaximalMarkovOrder()
This method returns the maximal used Markov order.

Returns:
maximal used Markov order

getLogPriorTerm

double getLogPriorTerm()
Returns a value that is proportional to the log of the prior. For maximum likelihood (ML) 0 should be returned.

Returns:
a value that is proportional to the log of the prior
See Also:
StatisticalModel.getLogPriorTerm()

getNumberOfStates

int getNumberOfStates()
This method returns the number of states underlying this transition instance.

Returns:
the number of states underlying this transition instance

initializeRandomly

void initializeRandomly()
This method randomly initializes the parameters of the transition.


getGraphizNetworkRepresentation

String getGraphizNetworkRepresentation(NumberFormat nf,
                                       String arrowOption,
                                       boolean graphical)
This method returns a String representation of the structure that can be used in Graphviz to create an image.

Parameters:
nf - the NumberFormat used for the probabilities, if null no probabilities will we written
arrowOption - this parameter gives the possibility to set some arrow option
graphical - represent transition probabilities as thickness of edges instead of textual output
Returns:
String representation of the state

fillTransitionInformation

void fillTransitionInformation(int layer,
                               int index,
                               int childIdx,
                               int[] container)
This method fills all relevant information for a specific edge in a given container.

Parameters:
layer - the layer in the matrix
index - the index encoding the context
childIdx - the index of the child that will be visited
container - container[0] the index of the state; container[1] the index encoding the new context; container[2] the distance for the new layer, i.e. 0 for the same layer (=silent state), and 1 for the next layer (=non-silent state)

getLogScoreFor

double getLogScoreFor(int layer,
                      int index,
                      int childIdx,
                      Sequence sequence,
                      int sequencePosition)
This method returns the logarithm of the score for the transition.

Parameters:
layer - the layer in the matrix
index - the index encoding the context
childIdx - the index of the child that will be visited
sequence - the sequence
sequencePosition - the position within the sequence
Returns:
the logarithm of the score for the transition

getNumberOfIndexes

int getNumberOfIndexes(int layer)
This method computes the number of different indexes for a given layer of the matrix.

Parameters:
layer - the layer of the matrix
Returns:
the number of different indexes for a given position

hasAnySelfTransitions

boolean hasAnySelfTransitions()
This method answers the question whether the instance models any self transitions. It returns true if the current instance has any self transitions, otherwise false

Returns:
true if the current instance has any self transitions, otherwise false

getMaximalInDegree

int getMaximalInDegree()
This method returns the maximal out degree of any context used in this transition instance.

Returns:
maximal out degree of any context

getMaximalNumberOfChildren

int getMaximalNumberOfChildren()
This method returns the maximal number of children for any context used in this transition instance.

Returns:
maximal number of children for any context

getLastContextState

int getLastContextState(int layer,
                        int index)
The method returns the index of the state of the context, if there is no context -1 is returned.

Parameters:
layer - the layer in the matrix
index - the index encoding the context
Returns:
the index of the last state of the context, if there is no context -1 is returned

getChildIdx

int getChildIdx(int layer,
                int index,
                int state)
This method returns the child index of the state, if this state is no child of the context -1 is returned

Parameters:
layer - the layer in the matrix
index - the index encoding the context
state - the index of the state
Returns:
the child index of the state, if this state is no child of the context -1 is returned

isAbsoring

boolean[] isAbsoring()
This method returns for each state whether it is absorbing or not.

Returns:
for each state whether it is absorbing or not

toString

String toString(String[] stateNames,
                NumberFormat nf)
This method returns a String representation of the Transition using the given names of the states.

Parameters:
stateNames - the names of the states, can be null
nf - the NumberFormat for the String representation of probabilities
Returns:
a String representation of the Transition using the given names of the states

setParameters

void setParameters(Transition t)
                   throws IllegalArgumentException
Set values of parameters of the instance to the value of the parameters of the given instance. It can be assumed that the given instance and the current instance are from the same class. This method might be used for instance in a multi-threaded optimization to broadcast the parameters.

Parameters:
t - the transition with the parameters to be set
Throws:
IllegalArgumentException - if the assumption about the same class for given and current instance is wrong