de.jstacs.sequenceScores.statisticalModels.differentiable
Class AbstractVariableLengthDiffSM

java.lang.Object
  extended by de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
      extended by de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractDifferentiableStatisticalModel
          extended by de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractVariableLengthDiffSM
All Implemented Interfaces:
DifferentiableSequenceScore, SequenceScore, DifferentiableStatisticalModel, VariableLengthDiffSM, StatisticalModel, Storable, Cloneable
Direct Known Subclasses:
CyclicMarkovModelDiffSM, HomogeneousDiffSM

public abstract class AbstractVariableLengthDiffSM
extends AbstractDifferentiableStatisticalModel
implements VariableLengthDiffSM

This abstract class implements some methods declared in DifferentiableStatisticalModel based on the declaration of methods in VariableLengthDiffSM. It allows to score subsequences of arbitrary length. This DifferentiableStatisticalModel should be the super class for non-motif DifferentiableStatisticalModels like homogeneous Markov models, cyclic Markov models, ... etc.

Author:
Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
alphabets, length, r
 
Fields inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
UNKNOWN
 
Constructor Summary
protected AbstractVariableLengthDiffSM(AlphabetContainer alphabets)
          This is the main constructor that creates an instance of a VariableLengthDiffSM that models sequences of arbitrary length.
protected AbstractVariableLengthDiffSM(AlphabetContainer alphabets, int length)
          This is the main constructor that creates an instance of a VariableLengthDiffSM that models sequences of a given length.
protected AbstractVariableLengthDiffSM(StringBuffer source)
          This is the constructor for the interface Storable.
 
Method Summary
 double getLogNormalizationConstant()
          Returns the logarithm of the sum of the scores over all sequences of the event space.
 double getLogPartialNormalizationConstant(int parameterIndex)
          Returns the logarithm of the partial normalization constant for the parameter with index parameterIndex.
abstract  double getLogScoreAndPartialDerivation(Sequence seq, int startpos, int endpos, IntList indices, DoubleList partialDer)
          Returns the logarithmic score for a Sequence beginning at position start in the Sequence and fills lists with the indices and the partial derivations.
 double getLogScoreAndPartialDerivation(Sequence seq, int start, IntList indices, DoubleList dList)
          Returns the logarithmic score for a Sequence beginning at position start in the Sequence and fills lists with the indices and the partial derivations.
 double getLogScoreFor(Sequence seq, int start)
          Returns the logarithmic score for the Sequence seq beginning at position start in the Sequence.
abstract  double getLogScoreFor(Sequence seq, int startpos, int endpos)
          Returns the logarithmic score for the Sequence seq beginning at position start in the Sequence.
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractDifferentiableStatisticalModel
clone, emitDataSet, getInitialClassParam, getLogProbFor, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getMaximalMarkovOrder, isNormalized, isNormalized
 
Methods inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
fromXML, getAlphabetContainer, getCharacteristics, getLength, getLogScoreAndPartialDerivation, getLogScoreFor, getNumberOfRecommendedStarts, getNumberOfStarts, getNumericalCharacteristics
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.differentiable.VariableLengthDiffSM
getLogNormalizationConstant, getLogPartialNormalizationConstant, setStatisticForHyperparameters
 
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.differentiable.DifferentiableStatisticalModel
addGradientOfLogPriorTerm, getESS, getLogPriorTerm, getSizeOfEventSpaceForRandomVariablesOfParameter, isNormalized
 
Methods inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
clone, getCurrentParameterValues, getInitialClassParam, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, setParameters
 
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.StatisticalModel
emitDataSet, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrder
 
Methods inherited from interface de.jstacs.sequenceScores.SequenceScore
getAlphabetContainer, getCharacteristics, getInstanceName, getLength, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumericalCharacteristics, isInitialized, toString
 
Methods inherited from interface de.jstacs.Storable
toXML
 

Constructor Detail

AbstractVariableLengthDiffSM

protected AbstractVariableLengthDiffSM(AlphabetContainer alphabets)
This is the main constructor that creates an instance of a VariableLengthDiffSM that models sequences of arbitrary length.

Parameters:
alphabets - the AlphabetContainer of this VariableLengthDiffSM
See Also:
AbstractVariableLengthDiffSM(AlphabetContainer, int)

AbstractVariableLengthDiffSM

protected AbstractVariableLengthDiffSM(AlphabetContainer alphabets,
                                       int length)
This is the main constructor that creates an instance of a VariableLengthDiffSM that models sequences of a given length.

Parameters:
alphabets - the AlphabetContainer of this VariableLengthDiffSM
length - the length of the modeled sequences

AbstractVariableLengthDiffSM

protected AbstractVariableLengthDiffSM(StringBuffer source)
                                throws NonParsableException
This is the constructor for the interface Storable. Creates a new VariableLengthDiffSM out of its XML representation.

Parameters:
source - the XML representation as StringBuffer
Throws:
NonParsableException - if the XML representation could not be parsed.
Method Detail

getLogNormalizationConstant

public double getLogNormalizationConstant()
Description copied from interface: DifferentiableStatisticalModel
Returns the logarithm of the sum of the scores over all sequences of the event space.

Specified by:
getLogNormalizationConstant in interface DifferentiableStatisticalModel
Returns:
the logarithm of the normalization constant Z

getLogPartialNormalizationConstant

public double getLogPartialNormalizationConstant(int parameterIndex)
                                          throws Exception
Description copied from interface: DifferentiableStatisticalModel
Returns the logarithm of the partial normalization constant for the parameter with index parameterIndex. This is the logarithm of the partial derivation of the normalization constant for the parameter with index parameterIndex,
\[\log \frac{\partial Z(\underline{\lambda})}{\partial \lambda_{parameterindex}}\]
.

Specified by:
getLogPartialNormalizationConstant in interface DifferentiableStatisticalModel
Parameters:
parameterIndex - the index of the parameter
Returns:
the logarithm of the partial normalization constant
Throws:
Exception - if something went wrong with the normalization
See Also:
DifferentiableStatisticalModel.getLogNormalizationConstant()

getLogScoreFor

public double getLogScoreFor(Sequence seq,
                             int start)
Description copied from interface: SequenceScore
Returns the logarithmic score for the Sequence seq beginning at position start in the Sequence.

Specified by:
getLogScoreFor in interface SequenceScore
Parameters:
seq - the Sequence
start - the start position in the Sequence
Returns:
the logarithmic score for the Sequence

getLogScoreAndPartialDerivation

public double getLogScoreAndPartialDerivation(Sequence seq,
                                              int start,
                                              IntList indices,
                                              DoubleList dList)
Description copied from interface: DifferentiableSequenceScore
Returns the logarithmic score for a Sequence beginning at position start in the Sequence and fills lists with the indices and the partial derivations.

Specified by:
getLogScoreAndPartialDerivation in interface DifferentiableSequenceScore
Parameters:
seq - the Sequence
start - the start position in the Sequence
indices - an IntList of indices, after method invocation the list should contain the indices i where $\frac{\partial \log score(seq)}{\partial \lambda_i}$ is not zero
dList - a DoubleList of partial derivations, after method invocation the list should contain the corresponding $\frac{\partial \log score(seq)}{\partial \lambda_i}$ that are not zero
Returns:
the logarithmic score for the Sequence

getLogScoreFor

public abstract double getLogScoreFor(Sequence seq,
                                      int startpos,
                                      int endpos)
Description copied from interface: SequenceScore
Returns the logarithmic score for the Sequence seq beginning at position start in the Sequence.

Specified by:
getLogScoreFor in interface SequenceScore
Specified by:
getLogScoreFor in interface VariableLengthDiffSM
Overrides:
getLogScoreFor in class AbstractDifferentiableSequenceScore
Parameters:
seq - the Sequence
startpos - the start position in the Sequence
endpos - the end position (inclusive) in the Sequence
Returns:
the logarithmic score for the Sequence

getLogScoreAndPartialDerivation

public abstract double getLogScoreAndPartialDerivation(Sequence seq,
                                                       int startpos,
                                                       int endpos,
                                                       IntList indices,
                                                       DoubleList partialDer)
Description copied from interface: DifferentiableSequenceScore
Returns the logarithmic score for a Sequence beginning at position start in the Sequence and fills lists with the indices and the partial derivations.

Specified by:
getLogScoreAndPartialDerivation in interface DifferentiableSequenceScore
Specified by:
getLogScoreAndPartialDerivation in interface VariableLengthDiffSM
Overrides:
getLogScoreAndPartialDerivation in class AbstractDifferentiableSequenceScore
Parameters:
seq - the Sequence
startpos - the start position in the Sequence
endpos - the end position (inclusive) in the Sequence
indices - an IntList of indices, after method invocation the list should contain the indices i where $\frac{\partial \log score(seq)}{\partial \lambda_i}$ is not zero
partialDer - a DoubleList of partial derivations, after method invocation the list should contain the corresponding $\frac{\partial \log score(seq)}{\partial \lambda_i}$ that are not zero
Returns:
the logarithmic score for the Sequence