de.jstacs.scoringFunctions.mix
Class VariableLengthMixtureScoringFunction

java.lang.Object
  extended by de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
      extended by de.jstacs.scoringFunctions.mix.AbstractMixtureScoringFunction
          extended by de.jstacs.scoringFunctions.mix.MixtureScoringFunction
              extended by de.jstacs.scoringFunctions.mix.VariableLengthMixtureScoringFunction
All Implemented Interfaces:
MotifDiscoverer, MutableMotifDiscoverer, NormalizableScoringFunction, ScoringFunction, VariableLengthScoringFunction, Storable, Cloneable

public class VariableLengthMixtureScoringFunction
extends MixtureScoringFunction
implements VariableLengthScoringFunction

This class implements a mixture of VariableLengthScoringFunction by extending MixtureScoringFunction and implementing the methods of VariableLengthScoringFunction.

Author:
Jens Keilwagen

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.jstacs.motifDiscovery.MotifDiscoverer
MotifDiscoverer.KindOfProfile
 
Field Summary
 
Fields inherited from class de.jstacs.scoringFunctions.mix.AbstractMixtureScoringFunction
componentScore, dList, freeParams, function, hiddenParameter, hiddenPotential, iList, logGammaSum, logHiddenNorm, logHiddenPotential, norm, optimizeHidden, paramRef, partNorm
 
Fields inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
alphabets, length, r
 
Fields inherited from interface de.jstacs.scoringFunctions.ScoringFunction
UNKNOWN
 
Constructor Summary
VariableLengthMixtureScoringFunction(int starts, boolean plugIn, VariableLengthScoringFunction... component)
          This constructor creates a new VariableLengthMixtureScoringFunction.
VariableLengthMixtureScoringFunction(StringBuffer xml)
          This is the constructor for the interface Storable.
 
Method Summary
 double getLogNormalizationConstant(int length)
          This method returns the logarithm of the normalization constant for a given sequence length.
 double getLogPartialNormalizationConstant(int parameterIndex, int length)
          This method returns the logarithm of the partial normalization constant for a given parameter index and a sequence length.
 double getLogScore(Sequence seq, int start, int length)
          This method computes the logarithm of the score for a given subsequence.
 double getLogScoreAndPartialDerivation(Sequence seq, int start, int length, IntList indices, DoubleList partialDer)
          This method computes the logarithm of the score and the partial derivations for a given subsequence.
 void setStatisticForHyperparameters(int[] length, double[] weight)
          This method sets the hyperparameters for the model parameters by evaluating the given statistic.
 
Methods inherited from class de.jstacs.scoringFunctions.mix.MixtureScoringFunction
adjustHiddenParameters, clone, fillComponentScores, getEss, getGlobalIndexOfMotifInComponent, getHyperparameterForHiddenParameter, getIndexOfMaximalComponentFor, getInstanceName, getLogNormalizationConstantForComponent, getLogPartialNormalizationConstant, getLogScoreAndPartialDerivation, getMotifLength, getNumberOfMotifs, getNumberOfMotifsInComponent, getProfileOfScoresFor, getStrandProbabilitiesFor, initializeMotif, initializeMotifRandomly, initializeUsingPlugIn, modifyMotif, toString
 
Methods inherited from class de.jstacs.scoringFunctions.mix.AbstractMixtureScoringFunction
addGradientOfLogPriorTerm, cloneFunctions, computeHiddenParameter, computeLogGammaSum, determineIsNormalized, extractFurtherInformation, fromXML, getCurrentParameterValues, getFunction, getFunctions, getFurtherInformation, getIndexOfMaximalComponentFor, getIndices, getLogNormalizationConstant, getLogPriorTerm, getLogScore, getNumberOfComponents, getNumberOfParameters, getNumberOfRecommendedStarts, getProbsForComponent, getScoringFunctions, getSizeOfEventSpaceForRandomVariablesOfParameter, getXMLTag, init, initializeFunction, initializeFunctionRandomly, initializeHiddenPotentialRandomly, initializeHiddenUniformly, initWithLength, isInitialized, isNormalized, precomputeNorm, setHiddenParameters, setParameters, setParametersForFunction, toXML
 
Methods inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
getAlphabetContainer, getInitialClassParam, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfStarts, isNormalized
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.jstacs.scoringFunctions.NormalizableScoringFunction
addGradientOfLogPriorTerm, getEss, getInitialClassParam, getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogPriorTerm, getSizeOfEventSpaceForRandomVariablesOfParameter, isNormalized
 
Methods inherited from interface de.jstacs.scoringFunctions.ScoringFunction
clone, getAlphabetContainer, getCurrentParameterValues, getInstanceName, getLength, getLogScore, getLogScore, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, isInitialized, setParameters
 
Methods inherited from interface de.jstacs.Storable
toXML
 
Methods inherited from interface de.jstacs.motifDiscovery.MotifDiscoverer
getNumberOfComponents
 

Constructor Detail

VariableLengthMixtureScoringFunction

public VariableLengthMixtureScoringFunction(int starts,
                                            boolean plugIn,
                                            VariableLengthScoringFunction... component)
                                     throws CloneNotSupportedException
This constructor creates a new VariableLengthMixtureScoringFunction.

Parameters:
starts - the number of starts that should be done in an optimization
plugIn - indicates whether the initial parameters for an optimization should be related to the data or randomly drawn
component - the VariableLengthScoringFunctions
Throws:
CloneNotSupportedException - if an element of component could not be cloned

VariableLengthMixtureScoringFunction

public VariableLengthMixtureScoringFunction(StringBuffer xml)
                                     throws NonParsableException
This is the constructor for the interface Storable. Creates a new VariableLengthMixtureScoringFunction out of a StringBuffer.

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

getLogScore

public double getLogScore(Sequence seq,
                          int start,
                          int length)
Description copied from interface: VariableLengthScoringFunction
This method computes the logarithm of the score for a given subsequence.

Specified by:
getLogScore in interface VariableLengthScoringFunction
Parameters:
seq - the Sequence
start - the start index in the Sequence
length - the length of the Sequence beginning at start
Returns:
the logarithm of the score for the subsequence
See Also:
ScoringFunction.getLogScore(Sequence, int)

getLogScoreAndPartialDerivation

public double getLogScoreAndPartialDerivation(Sequence seq,
                                              int start,
                                              int length,
                                              IntList indices,
                                              DoubleList partialDer)
Description copied from interface: VariableLengthScoringFunction
This method computes the logarithm of the score and the partial derivations for a given subsequence.

Specified by:
getLogScoreAndPartialDerivation in interface VariableLengthScoringFunction
Parameters:
seq - the Sequence
start - the start index in the Sequence
length - the end index 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 logarithm of the score
See Also:
ScoringFunction.getLogScoreAndPartialDerivation(Sequence, int, IntList, DoubleList)

getLogNormalizationConstant

public double getLogNormalizationConstant(int length)
Description copied from interface: VariableLengthScoringFunction
This method returns the logarithm of the normalization constant for a given sequence length.

Specified by:
getLogNormalizationConstant in interface VariableLengthScoringFunction
Parameters:
length - the sequence length
Returns:
the logarithm of the normalization constant
See Also:
NormalizableScoringFunction.getLogNormalizationConstant()

getLogPartialNormalizationConstant

public double getLogPartialNormalizationConstant(int parameterIndex,
                                                 int length)
                                          throws Exception
Description copied from interface: VariableLengthScoringFunction
This method returns the logarithm of the partial normalization constant for a given parameter index and a sequence length.

Specified by:
getLogPartialNormalizationConstant in interface VariableLengthScoringFunction
Parameters:
parameterIndex - the index of the parameter
length - the sequence length
Returns:
the logarithm of the partial normalization constant
Throws:
Exception - if something went wrong
See Also:
NormalizableScoringFunction.getLogPartialNormalizationConstant(int)

setStatisticForHyperparameters

public void setStatisticForHyperparameters(int[] length,
                                           double[] weight)
                                    throws Exception
Description copied from interface: VariableLengthScoringFunction
This method sets the hyperparameters for the model parameters by evaluating the given statistic. The statistic can be interpreted as follows: The model has seen a number of sequences. From these sequences it is only known how long (length) and how often ( weight) they have been seen.

Specified by:
setStatisticForHyperparameters in interface VariableLengthScoringFunction
Parameters:
length - the non-negative lengths of the sequences
weight - the non-negative weight for the corresponding sequence
Throws:
Exception - if something went wrong
See Also:
Mutable