de.jstacs.sequenceScores.statisticalModels.differentiable.mixture
Class VariableLengthMixtureDiffSM

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.mixture.AbstractMixtureDiffSM
              extended by de.jstacs.sequenceScores.statisticalModels.differentiable.mixture.MixtureDiffSM
                  extended by de.jstacs.sequenceScores.statisticalModels.differentiable.mixture.VariableLengthMixtureDiffSM
All Implemented Interfaces:
MotifDiscoverer, MutableMotifDiscoverer, DifferentiableSequenceScore, SequenceScore, DifferentiableStatisticalModel, SamplingDifferentiableStatisticalModel, VariableLengthDiffSM, StatisticalModel, Storable, Cloneable

public class VariableLengthMixtureDiffSM
extends MixtureDiffSM
implements VariableLengthDiffSM

This class implements a mixture of VariableLengthDiffSM by extending MixtureDiffSM and implementing the methods of VariableLengthDiffSM.

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.sequenceScores.statisticalModels.differentiable.mixture.AbstractMixtureDiffSM
componentScore, dList, freeParams, function, hiddenParameter, hiddenPotential, iList, logGammaSum, logHiddenNorm, logHiddenPotential, norm, optimizeHidden, paramRef, partNorm
 
Fields inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
alphabets, length, r
 
Fields inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
UNKNOWN
 
Constructor Summary
VariableLengthMixtureDiffSM(int starts, boolean plugIn, VariableLengthDiffSM... component)
          This constructor creates a new VariableLengthMixtureDiffSM.
VariableLengthMixtureDiffSM(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 getLogScoreAndPartialDerivation(Sequence seq, int start, int end, 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 getLogScoreFor(Sequence seq, int start, int end)
          Returns the logarithmic score for the Sequence seq beginning at position start in the Sequence.
 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.sequenceScores.statisticalModels.differentiable.mixture.MixtureDiffSM
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.sequenceScores.statisticalModels.differentiable.mixture.AbstractMixtureDiffSM
addGradientOfLogPriorTerm, cloneFunctions, computeHiddenParameter, computeLogGammaSum, determineIsNormalized, extractFurtherInformation, fromXML, getCurrentParameterValues, getDifferentiableStatisticalModels, getFunction, getFunctions, getFurtherInformation, getIndexOfMaximalComponentFor, getIndices, getLogNormalizationConstant, getLogPriorTerm, getLogScoreFor, getNumberOfComponents, getNumberOfParameters, getNumberOfRecommendedStarts, getProbsForComponent, getSamplingGroups, getSizeOfEventSpaceForRandomVariablesOfParameter, getXMLTag, init, initializeFunction, initializeFunctionRandomly, initializeHiddenPotentialRandomly, initializeHiddenUniformly, initWithLength, isInitialized, isNormalized, precomputeNorm, setHiddenParameters, setParameters, setParametersForFunction, toXML
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractDifferentiableStatisticalModel
emitDataSet, getInitialClassParam, getLogProbFor, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getMaximalMarkovOrder, isNormalized
 
Methods inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
getAlphabetContainer, getCharacteristics, getLength, getLogScoreAndPartialDerivation, getLogScoreFor, 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.DifferentiableStatisticalModel
addGradientOfLogPriorTerm, getESS, getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogPriorTerm, getSizeOfEventSpaceForRandomVariablesOfParameter, isNormalized
 
Methods inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
clone, getCurrentParameterValues, getInitialClassParam, getLogScoreAndPartialDerivation, 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, getLogScoreFor, getNumericalCharacteristics, isInitialized, toString
 
Methods inherited from interface de.jstacs.Storable
toXML
 
Methods inherited from interface de.jstacs.motifDiscovery.MotifDiscoverer
getNumberOfComponents
 

Constructor Detail

VariableLengthMixtureDiffSM

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

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 VariableLengthDiffSMs
Throws:
CloneNotSupportedException - if an element of component could not be cloned

VariableLengthMixtureDiffSM

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

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

getLogScoreFor

public double getLogScoreFor(Sequence seq,
                             int start,
                             int end)
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
start - the start position in the Sequence
end - the end position (inclusive) in the Sequence
Returns:
the logarithmic score for the Sequence

getLogScoreAndPartialDerivation

public double getLogScoreAndPartialDerivation(Sequence seq,
                                              int start,
                                              int end,
                                              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
start - the start position in the Sequence
end - 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

getLogNormalizationConstant

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

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

getLogPartialNormalizationConstant

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

Specified by:
getLogPartialNormalizationConstant in interface VariableLengthDiffSM
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:
DifferentiableStatisticalModel.getLogPartialNormalizationConstant(int)

setStatisticForHyperparameters

public void setStatisticForHyperparameters(int[] length,
                                           double[] weight)
                                    throws Exception
Description copied from interface: VariableLengthDiffSM
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 VariableLengthDiffSM
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