|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.BasicHigherOrderTransition
public class BasicHigherOrderTransition
This class implements the basic transition that allows to be trained using the viterbi or the Baum-Welch algorithm. Layer 0, context 0 encodes the start state.
| Nested Class Summary | |
|---|---|
static class |
BasicHigherOrderTransition.AbstractTransitionElement
This class declares the probability distribution for a given context, i.e. it contains all possible transition and the corresponding probabilities for a given set offset previously visited states. |
| Field Summary | |
|---|---|
protected boolean[] |
isSilent
A vector indicating for each state whether it is silent or not. |
protected int[][][] |
lookup
The lookup table for spare context en- and decoding. |
protected int |
maximalMarkovOrder
The maximal Markov order of the transition. |
protected int |
maxInDegree
The maximal in-degree of any state. |
protected BasicHigherOrderTransition.AbstractTransitionElement[] |
transitions
The internally used BasicHigherOrderTransition.AbstractTransitionElements. |
| Constructor Summary | |
|---|---|
BasicHigherOrderTransition(boolean[] isSilent,
BasicHigherOrderTransition.AbstractTransitionElement... transitions)
The main constructor. |
|
BasicHigherOrderTransition(StringBuffer xml)
The standard constructor for the interface Storable. |
|
| Method Summary | |
|---|---|
void |
addToStatistic(int layer,
int index,
int childIdx,
double weight,
Sequence sequence,
int sequencePosition)
This method allows to add a certain weight to the sufficient statistic of a specific transition. |
protected void |
appendFurtherInformation(StringBuffer xml)
This method appends further information to the XML representation. |
BasicHigherOrderTransition |
clone()
This method returns a deep clone of the current instance. |
void |
drawParametersFromStatistic()
This method allows to draw parameters from the sufficient statistic, i.e., to draw from the posterior. |
void |
estimateFromStatistic()
This method estimates the parameter of the transition using the internal sufficient statistic. |
protected void |
extractFurtherInformation(StringBuffer xml)
This method extracts further information from the XML representation. |
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 |
getLogGammaScoreFromStatistic()
This method calculates a score for the current statistics, which is independent from the current parameters In general the gamma-score is a product of gamma-functions parameterized with the current statistics |
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. context, and a given layer of the matrix. |
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. |
protected int |
getTransitionElementIndex(int layer,
int index)
This method return the index of the BasicHigherOrderTransition.AbstractTransitionElement using the lookup table. |
protected String |
getXMLTag()
The method returns the XML tag used during saving and loading the transition. |
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 |
joinStatistics(Transition... transitions)
This method joins the statistics of different instances and sets this joined statistic as statistic of each instance. |
void |
resetStatistic()
This method reset the internal sufficient statistics that can be used for estimating the parameters. |
void |
setParameters(Transition t)
Set values of parameters of the instance to the value of the parameters of the given instance. |
String |
toString()
|
String |
toString(String[] stateNames)
This method returns a String representation of the Transition using the given names of the states. |
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected BasicHigherOrderTransition.AbstractTransitionElement[] transitions
BasicHigherOrderTransition.AbstractTransitionElements.
protected boolean[] isSilent
protected int maximalMarkovOrder
protected int maxInDegree
protected int[][][] lookup
| Constructor Detail |
|---|
public BasicHigherOrderTransition(boolean[] isSilent,
BasicHigherOrderTransition.AbstractTransitionElement... transitions)
throws Exception
transitions - the BasicHigherOrderTransition.AbstractTransitionElements for the internal useisSilent - an array indicating for each state whether it is silent or not
Exception - if an error occurs during checking the BasicHigherOrderTransition.AbstractTransitionElements and creating internal fields
public BasicHigherOrderTransition(StringBuffer xml)
throws NonParsableException
Storable.
Constructs a BasicHigherOrderTransition out of an XML representation.
xml - the XML representation as StringBuffer
NonParsableException - if the BasicHigherOrderTransition could not be reconstructed out of
the StringBuffer xml| Method Detail |
|---|
public StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.
toXML in interface Storableprotected String getXMLTag()
protected void appendFurtherInformation(StringBuffer xml)
xml - the XML representation
protected void extractFurtherInformation(StringBuffer xml)
throws NonParsableException
xml - the XML representation
NonParsableException - if the information could not be reconstructed out of the StringBuffer xml
public BasicHigherOrderTransition clone()
throws CloneNotSupportedException
Transition
clone in interface Transitionclone in class ObjectCloneNotSupportedException - if the instance could not be clonedpublic void resetStatistic()
TransitionWithSufficientStatistic
resetStatistic in interface TransitionWithSufficientStatisticpublic void joinStatistics(Transition... transitions)
TransitionWithSufficientStatistic
joinStatistics in interface TransitionWithSufficientStatistictransitions - the transitions to be joined
public void addToStatistic(int layer,
int index,
int childIdx,
double weight,
Sequence sequence,
int sequencePosition)
TransitionWithSufficientStatisticweight to the sufficient statistic of a specific transition.
addToStatistic in interface TransitionWithSufficientStatisticlayer - the layer of the matrixindex - the index encoding the contextchildIdx - the index of the childweight - the weight added to the sufficient statisticsequence - the sequencesequencePosition - the position within the sequencepublic void estimateFromStatistic()
TrainableTransition
estimateFromStatistic in interface TrainableTransition
public void drawParametersFromStatistic()
throws Exception
addToStatistic(int, int, int, double, Sequence, int), the method draws from the prior.
Exception - if for instance the prior has some illegal hyper-parameters (e.g. 0)BasicHigherOrderTransition.AbstractTransitionElement.drawParametersFromStatistic()public int getMaximalMarkovOrder()
Transition
getMaximalMarkovOrder in interface Transitionpublic double getLogPriorTerm()
Transition
getLogPriorTerm in interface TransitionStatisticalModel.getLogPriorTerm()public int getNumberOfStates()
Transition
getNumberOfStates in interface Transitionpublic void initializeRandomly()
Transition
initializeRandomly in interface Transition
public String getGraphizNetworkRepresentation(NumberFormat nf,
String arrowOption,
boolean graphical)
TransitionString representation of the structure that
can be used in Graphviz to create an image.
getGraphizNetworkRepresentation in interface Transitionnf - the NumberFormat used for the probabilities, if
null no probabilities will we writtenarrowOption - this parameter gives the possibility to set some arrow optiongraphical - represent transition probabilities as thickness of edges
instead of textual output
String representation of the state
public void fillTransitionInformation(int layer,
int index,
int childIdx,
int[] container)
Transition
fillTransitionInformation in interface Transitionlayer - the layer in the matrixindex - the index encoding the contextchildIdx - the index of the child that will be visitedcontainer - 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)
protected final int getTransitionElementIndex(int layer,
int index)
BasicHigherOrderTransition.AbstractTransitionElement using the lookup table.
layer - the layer of the matrixindex - the index encoding the context
BasicHigherOrderTransition.AbstractTransitionElement with respect to transitions
public int getNumberOfChildren(int layer,
int index)
Transition
getNumberOfChildren in interface Transitionlayer - the layer of the matrixindex - the index encoding the context
public double getLogScoreFor(int layer,
int index,
int childIdx,
Sequence sequence,
int sequencePosition)
Transition
getLogScoreFor in interface Transitionlayer - the layer in the matrixindex - the index encoding the contextchildIdx - the index of the child that will be visitedsequence - the sequencesequencePosition - the position within the sequence
public int getNumberOfIndexes(int layer)
Transition
getNumberOfIndexes in interface Transitionlayer - the layer of the matrix
public boolean hasAnySelfTransitions()
Transitiontrue if the current instance has
any self transitions, otherwise false
hasAnySelfTransitions in interface Transitiontrue if the current instance has any self
transitions, otherwise falsepublic int getMaximalInDegree()
Transition
getMaximalInDegree in interface Transitionpublic int getMaximalNumberOfChildren()
Transition
getMaximalNumberOfChildren in interface Transition
public int getLastContextState(int layer,
int index)
Transition
getLastContextState in interface Transitionlayer - the layer in the matrixindex - the index encoding the context
public int getChildIdx(int layer,
int index,
int state)
Transition
getChildIdx in interface Transitionlayer - the layer in the matrixindex - the index encoding the contextstate - the index of the state
public double getLogGammaScoreFromStatistic()
TransitionWithSufficientStatistic
getLogGammaScoreFromStatistic in interface TransitionWithSufficientStatisticpublic String toString()
toString in class Objectpublic String toString(String[] stateNames)
TransitionString representation of the Transition using the given names of the states.
toString in interface TransitionstateNames - the names of the states, can be null
String representation of the Transition using the given names of the statespublic boolean[] isAbsoring()
Transition
isAbsoring in interface Transition
public void setParameters(Transition t)
throws IllegalArgumentException
Transition
setParameters in interface Transitiont - the transition with the parameters to be set
IllegalArgumentException - if the assumption about the same class for given and current instance is wrong
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||