de.jstacs.scoringFunctions
Class AbstractVariableLengthScoringFunction

java.lang.Object
  extended by de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
      extended by de.jstacs.scoringFunctions.AbstractVariableLengthScoringFunction
All Implemented Interfaces:
NormalizableScoringFunction, ScoringFunction, VariableLengthScoringFunction, Storable, Cloneable
Direct Known Subclasses:
CMMScoringFunction, HomogeneousScoringFunction

public abstract class AbstractVariableLengthScoringFunction
extends AbstractNormalizableScoringFunction
implements VariableLengthScoringFunction

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

Author:
Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
alphabets, length, r
 
Fields inherited from interface de.jstacs.scoringFunctions.ScoringFunction
UNKNOWN
 
Constructor Summary
protected AbstractVariableLengthScoringFunction(AlphabetContainer alphabets)
          This is the main constructor that creates an instance of a VariableLengthScoringFunction that models sequences of arbitrary length.
protected AbstractVariableLengthScoringFunction(AlphabetContainer alphabets, int length)
          This is the main constructor that creates an instance of a VariableLengthScoringFunction that models sequences of a given length.
protected AbstractVariableLengthScoringFunction(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.
 double getLogScore(Sequence seq, int start)
          Returns the logarithmic score for the Sequence seq beginning at position start in the Sequence.
 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.
 
Methods inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
clone, fromXML, getAlphabetContainer, getInitialClassParam, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfRecommendedStarts, getNumberOfStarts, isNormalized, isNormalized
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jstacs.scoringFunctions.VariableLengthScoringFunction
getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogScore, getLogScoreAndPartialDerivation, setStatisticForHyperparameters
 
Methods inherited from interface de.jstacs.scoringFunctions.NormalizableScoringFunction
addGradientOfLogPriorTerm, getEss, getInitialClassParam, getLogPriorTerm, getSizeOfEventSpaceForRandomVariablesOfParameter, isNormalized
 
Methods inherited from interface de.jstacs.scoringFunctions.ScoringFunction
clone, getAlphabetContainer, getCurrentParameterValues, getInstanceName, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, isInitialized, setParameters
 
Methods inherited from interface de.jstacs.Storable
toXML
 

Constructor Detail

AbstractVariableLengthScoringFunction

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

Parameters:
alphabets - the AlphabetContainer of this VariableLengthScoringFunction
See Also:
AbstractVariableLengthScoringFunction(AlphabetContainer, int)

AbstractVariableLengthScoringFunction

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

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

AbstractVariableLengthScoringFunction

protected AbstractVariableLengthScoringFunction(StringBuffer source)
                                         throws NonParsableException
This is the constructor for the interface Storable. Creates a new VariableLengthScoringFunction 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: NormalizableScoringFunction
Returns the logarithm of the sum of the scores over all sequences of the event space.

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

getLogPartialNormalizationConstant

public double getLogPartialNormalizationConstant(int parameterIndex)
                                          throws Exception
Description copied from interface: NormalizableScoringFunction
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 NormalizableScoringFunction
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:
NormalizableScoringFunction.getLogNormalizationConstant()

getLogScore

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

Specified by:
getLogScore in interface ScoringFunction
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: ScoringFunction
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 ScoringFunction
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