public class TransitionElement extends BasicTransitionElement
| Modifier and Type | Field and Description |
|---|---|
protected int |
offset
The internally used parameter offset.
|
protected double[] |
probs
The precomputed probabilities for each possible transition.
|
context, descendants, hyperParameters, logNorm, parameters, states, statistic| Constructor and Description |
|---|
TransitionElement(int[] context,
int[] states,
double[] hyperParameters)
This is the main constructor creating a new instance with given context, descendant states, and hyper parameters.
|
TransitionElement(int[] context,
int[] states,
double[] hyperParameters,
double[] weight)
This is the main constructor creating a new instance with given context, descendant states, and hyper parameters.
|
TransitionElement(StringBuffer xml)
The standard constructor for the interface
Storable. |
| Modifier and Type | Method and Description |
|---|---|
void |
addGradientForLogPriorTerm(double[] gradient,
int start)
This method computes the gradient of
BasicHigherOrderTransition.AbstractTransitionElement.getLogPriorTerm() for each
parameter of this transition element. |
TransitionElement |
clone() |
int |
fillParameters(double[] params,
int offset)
This method fills the current parameters of this
TransitionElement into the given array params
starting at position offset. |
double |
getLogPosteriorFromStatistic()
This method computes the log posterior from the internal sufficient statistic.
|
double |
getLogScoreAndPartialDerivation(int childIdx,
IntList indices,
DoubleList partialDer,
Sequence sequence,
int sequencePosition)
Returns the logarithmic score and fills lists with
the indices and the partial derivations.
|
double |
getMinimalHyperparameter()
This method returns the minimal hyper parameters of this
TransitionElement. |
protected void |
init()
This method initializes internal fields.
|
protected void |
precompute()
This method precomputes internal fields as for instance the normalization constant.
|
int |
setParameterOffset(int o)
This method sets the internal
offset used for several methods (cf. |
int |
setParameters(double[] params,
int start)
This method sets the internal parameters to the values of
params beginning at index start. |
appendFurtherInformation, extractFurtherInformationaddToStatistic, appendGraphvizDescription, appendTransitions, drawParametersFromStatistic, estimateFromStatistic, getArrowOption, getChild, getContext, getDescendant, getGraphvizEdgeWeight, getLabel, getLastContextState, getLogGammaScoreFromStatistic, getLogPriorTerm, getLogScoreFor, getNextContext, getNumberOfChildren, getNumberOfParameters, getXMLTag, initializeRandomly, joinStatistics, resetStatistic, setIndexOfDescendantTransitionElement, setParameters, toString, toString, toXMLprotected double[] probs
protected int offset
public TransitionElement(int[] context,
int[] states,
double[] hyperParameters)
context - the context (=previously visited state indices); last entry corresponds to the last state visitedstates - the transitions to all possible states; if null than no transition allowedhyperParameters - the hyper parameters for the transitions; if null than no prior is usedTransitionElement(int[], int[], double[], double[])public TransitionElement(int[] context,
int[] states,
double[] hyperParameters,
double[] weight)
context - the context (=previously visited state indices); last entry corresponds to the last state visitedstates - the transitions to all possible states; if null than no transition allowedhyperParameters - the hyper parameters for the transitions; if null than no prior is usedweight - the weight for plotting the edge in Graphviz, enables to modify the edge length, larger weights imply shorter edges (default: 1)public TransitionElement(StringBuffer xml) throws NonParsableException
Storable.
Constructs a TransitionElement out of an XML representation.xml - the XML representation as StringBufferNonParsableException - if the TransitionElement could not be reconstructed out of
the StringBuffer xmlpublic TransitionElement clone() throws CloneNotSupportedException
clone in class BasicHigherOrderTransition.AbstractTransitionElementCloneNotSupportedExceptionprotected void init()
BasicHigherOrderTransition.AbstractTransitionElementinit in class BasicHigherOrderTransition.AbstractTransitionElementprotected void precompute()
BasicHigherOrderTransition.AbstractTransitionElementprecompute in class BasicHigherOrderTransition.AbstractTransitionElementBasicHigherOrderTransition.AbstractTransitionElement.logNormpublic double getLogScoreAndPartialDerivation(int childIdx,
IntList indices,
DoubleList partialDer,
Sequence sequence,
int sequencePosition)
childIdx - the index of the child to be visitedindices - an IntList of indices, after method invocation the
list should contain the indices i where
is not zeropartialDer - a DoubleList of partial derivations, after method
invocation the list should contain the corresponding
that are not zerosequence - the Sequence that can be used to extract SequenceAnnotationsequencePosition - the position within the sequencepublic int setParameterOffset(int o)
offset used for several methods (cf. see tags).o - the offset to be setTransitionElementoffset,
getLogScoreAndPartialDerivation(int, IntList, DoubleList, Sequence, int),
addGradientForLogPriorTerm(double[], int)public int fillParameters(double[] params,
int offset)
TransitionElement into the given array params
starting at position offset.params - the array for filling the parametersoffset - the start indexpublic int setParameters(double[] params,
int start)
params beginning at index start.params - the new parametersstart - the start index in paramsparams that has not been usedpublic void addGradientForLogPriorTerm(double[] gradient,
int start)
BasicHigherOrderTransition.AbstractTransitionElement.getLogPriorTerm() for each
parameter of this transition element. The results are added to the array
gradient using the index start.gradient - the array of gradientsstart - the start index in the gradient array used to add
partial derivations for the parametersoffsetpublic double getMinimalHyperparameter()
TransitionElement.TransitionElementpublic double getLogPosteriorFromStatistic()