de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements
Class ScaledTransitionElement

java.lang.Object
  extended by de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.BasicHigherOrderTransition.AbstractTransitionElement
      extended by de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.BasicTransitionElement
          extended by de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.ReferenceBasedTransitionElement
              extended by de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.ScaledTransitionElement
All Implemented Interfaces:
Storable, Cloneable

public class ScaledTransitionElement
extends ReferenceBasedTransitionElement

Scaled transition element for an HMM with scaled transition matrices (SHMM).

Author:
Michael Seifert, Jens Keilwagen

Field Summary
protected  String[] arrowOptions
          The Graphviz options for distinguishing the arrows of the different transitions.
protected  double[] scalingFactor
          The scaling factors of the individual transition classes.
 
Fields inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.ReferenceBasedTransitionElement
annotationID, diagElement, ess, probabilities, statisticsTransitionProb
 
Fields inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.BasicHigherOrderTransition.AbstractTransitionElement
context, descendants, hyperParameters, logNorm, parameters, states, statistic
 
Constructor Summary
ScaledTransitionElement(int[] context, int[] states, double[] probabilities, double ess, double[] scalingFactor, String annotationID)
          Creates an object representing the transition probabilities of a Hidden Markov TrainableStatisticalModel with scaled transition matrices (SHMM) for the given context.
ScaledTransitionElement(StringBuffer xml)
          The standard constructor for the interface Storable.
 
Method Summary
 void addToStatistic(int childIdx, double weight, Sequence sequence, int sequencePosition)
          This method adds a given weight to the sufficient statistic for the parameters.
protected  void appendFurtherInformation(StringBuffer xml)
          This method appends further information to the XML representation.
protected  void appendTransitions(StringBuffer representation, String contextNodeRepresentation, NumberFormat nf, String arrowOption, boolean graphical)
          This method appends all edges of the transition element to a given Graphviz representation.
 ScaledTransitionElement clone()
           
 void estimateFromStatistic()
          This method estimates the parameters from the sufficient statistic.
protected  void extractFurtherInformation(StringBuffer xml)
          This method extracts further information from the XML representation.
protected  int getIndex(int pos, Sequence seq)
          Returns the index of the transition matrix used for the transition from pos - 1 to pos in sequences seq.
 double getLogScoreFor(int state, Sequence sequence, int sequencePosition)
          This method returns the score for the transition from the current context to the state with index index.
protected  String getXMLTag()
          This method returns the xml tag used in BasicHigherOrderTransition.AbstractTransitionElement.toXML().
protected  void init()
          This method initializes internal fields.
 void resetStatistic()
          This method resets the sufficient statistic for the parameters.
 String toString(String[] stateNames)
           
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.ReferenceBasedTransitionElement
determineDiagonalElement, getLogGammaScoreFromStatistic, getLogPriorTerm, initializeRandomly, precompute
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.BasicHigherOrderTransition.AbstractTransitionElement
appendGraphvizDescription, drawParametersFromStatistic, getArrowOption, getChild, getContext, getDescendant, getGraphvizEdgeWeight, getLabel, getNextContext, getNumberOfChildren, getNumberOfParameters, joinStatistics, setIndexOfDescendantTransitionElement, setParameters, toString, toString, toXML
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

arrowOptions

protected String[] arrowOptions
The Graphviz options for distinguishing the arrows of the different transitions.


scalingFactor

protected double[] scalingFactor
The scaling factors of the individual transition classes.

Constructor Detail

ScaledTransitionElement

public ScaledTransitionElement(int[] context,
                               int[] states,
                               double[] probabilities,
                               double ess,
                               double[] scalingFactor,
                               String annotationID)
Creates an object representing the transition probabilities of a Hidden Markov TrainableStatisticalModel with scaled transition matrices (SHMM) for the given context.

Parameters:
context - context of states
states - states that can be reached from the context
probabilities - transition probabilities from the context to the states
ess - ess
scalingFactor - scaling factor
annotationID - identifier for decoding transition classes

ScaledTransitionElement

public ScaledTransitionElement(StringBuffer xml)
                        throws NonParsableException
The standard constructor for the interface Storable. Constructs a ScaledTransitionElement out of an XML representation.

Parameters:
xml - the XML representation as StringBuffer
Throws:
NonParsableException - if the ScaledTransitionElement could not be reconstructed out of the StringBuffer xml
Method Detail

init

protected void init()
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method initializes internal fields.

Overrides:
init in class ReferenceBasedTransitionElement

clone

public ScaledTransitionElement clone()
                              throws CloneNotSupportedException
Overrides:
clone in class ReferenceBasedTransitionElement
Throws:
CloneNotSupportedException

getIndex

protected int getIndex(int pos,
                       Sequence seq)
Returns the index of the transition matrix used for the transition from pos - 1 to pos in sequences seq.

Parameters:
pos - position in seq
seq - sequences
Returns:
index of transition matrix

addToStatistic

public void addToStatistic(int childIdx,
                           double weight,
                           Sequence sequence,
                           int sequencePosition)
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method adds a given weight to the sufficient statistic for the parameters.

Overrides:
addToStatistic in class BasicHigherOrderTransition.AbstractTransitionElement
Parameters:
childIdx - the index of the descendant state
weight - the weight to be added
sequence - the sequence, which might be used to retrieve SequenceAnnotation
sequencePosition - the position within the sequence
See Also:
TransitionWithSufficientStatistic.addToStatistic(int, int, int, double, Sequence, int), BasicHigherOrderTransition.AbstractTransitionElement.statistic, BasicHigherOrderTransition.AbstractTransitionElement.resetStatistic(), BasicHigherOrderTransition.AbstractTransitionElement.estimateFromStatistic(), BasicHigherOrderTransition.AbstractTransitionElement.drawParametersFromStatistic()

resetStatistic

public void resetStatistic()
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method resets the sufficient statistic for the parameters.

Overrides:
resetStatistic in class BasicHigherOrderTransition.AbstractTransitionElement
See Also:
BasicHigherOrderTransition.AbstractTransitionElement.statistic, BasicHigherOrderTransition.AbstractTransitionElement.estimateFromStatistic(), BasicHigherOrderTransition.AbstractTransitionElement.drawParametersFromStatistic(), BasicHigherOrderTransition.AbstractTransitionElement.addToStatistic(int, double, Sequence, int), TransitionWithSufficientStatistic.resetStatistic()

estimateFromStatistic

public void estimateFromStatistic()
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method estimates the parameters from the sufficient statistic.

Overrides:
estimateFromStatistic in class BasicHigherOrderTransition.AbstractTransitionElement
See Also:
BasicHigherOrderTransition.AbstractTransitionElement.statistic, BasicHigherOrderTransition.AbstractTransitionElement.resetStatistic(), BasicHigherOrderTransition.AbstractTransitionElement.addToStatistic(int, double, Sequence, int), TrainableTransition.estimateFromStatistic()

getLogScoreFor

public double getLogScoreFor(int state,
                             Sequence sequence,
                             int sequencePosition)
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method returns the score for the transition from the current context to the state with index index.

Overrides:
getLogScoreFor in class BasicHigherOrderTransition.AbstractTransitionElement
Parameters:
state - the index of the child
sequence - the sequence, which might be used to retrieve SequenceAnnotation
sequencePosition - the position within the sequence
Returns:
the score for the transition from the current context to the state with index index

appendTransitions

protected void appendTransitions(StringBuffer representation,
                                 String contextNodeRepresentation,
                                 NumberFormat nf,
                                 String arrowOption,
                                 boolean graphical)
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method appends all edges of the transition element to a given Graphviz representation.

Overrides:
appendTransitions in class BasicHigherOrderTransition.AbstractTransitionElement
Parameters:
representation - the current Graphviz representation
contextNodeRepresentation - the String representation of the context node(s)
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
See Also:
BasicHigherOrderTransition.AbstractTransitionElement.appendGraphvizDescription(StringBuffer, NumberFormat, String, boolean), BasicHigherOrderTransition.AbstractTransitionElement.getArrowOption(NumberFormat, double, double, String, boolean)

appendFurtherInformation

protected void appendFurtherInformation(StringBuffer xml)
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method appends further information to the XML representation. It allows subclasses to save further parameters that are not defined in the superclass.

Overrides:
appendFurtherInformation in class ReferenceBasedTransitionElement
Parameters:
xml - the XML representation

extractFurtherInformation

protected void extractFurtherInformation(StringBuffer xml)
                                  throws NonParsableException
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method extracts further information from the XML representation. It allows subclasses to cast further parameters that are not defined in the superclass.

Overrides:
extractFurtherInformation in class ReferenceBasedTransitionElement
Parameters:
xml - the XML representation
Throws:
NonParsableException - if the information could not be reconstructed out of the StringBuffer xml

getXMLTag

protected String getXMLTag()
Description copied from class: BasicHigherOrderTransition.AbstractTransitionElement
This method returns the xml tag used in BasicHigherOrderTransition.AbstractTransitionElement.toXML().

Overrides:
getXMLTag in class BasicHigherOrderTransition.AbstractTransitionElement
Returns:
the xml tag used in BasicHigherOrderTransition.AbstractTransitionElement.toXML()

toString

public String toString(String[] stateNames)