de.jstacs.sequenceScores.statisticalModels.differentiable.mixture.motif
Class DurationDiffSM

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.motif.PositionDiffSM
              extended by de.jstacs.sequenceScores.statisticalModels.differentiable.mixture.motif.DurationDiffSM
All Implemented Interfaces:
DifferentiableSequenceScore, SequenceScore, DifferentiableStatisticalModel, StatisticalModel, Storable, Cloneable
Direct Known Subclasses:
MixtureDurationDiffSM, SkewNormalLikeDurationDiffSM, UniformDurationDiffSM

public abstract class DurationDiffSM
extends PositionDiffSM

This class is the super class for all one dimensional position scoring functions that can be used as durations for semi Markov models.

Author:
Jens Keilwagen
See Also:
ExtendedZOOPSDiffSM

Field Summary
protected  int delta
          The difference of maximal and minimal value.
protected  double ess
          The equivalent sample size.
protected  int max
          The maximal value.
protected  int min
          The minimal value.
 
Fields inherited from class de.jstacs.sequenceScores.statisticalModels.differentiable.mixture.motif.PositionDiffSM
internal
 
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 DurationDiffSM(int min, int max, double ess)
          The default constructor.
protected DurationDiffSM(StringBuffer source)
          This is the constructor for Storable.
 
Method Summary
abstract  void adjust(int[] length, double[] weight)
          This method adjust the parameter based on the given statistic.
protected  void fromXML(StringBuffer xml)
          This method is called in the constructor for the Storable interface to create a scoring function from a StringBuffer.
 double getESS()
          Returns the equivalent sample size (ess) of this model, i.e.
 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.
 int getMax()
          Returns the maximal value that can be scored.
 int getMin()
          Returns the minimal value that can be scored.
 int getNumberOfPossibilities()
          Returns the number of different possibilities that can be scored.
protected abstract  String getRNotation(String distributionName, NumberFormat nf)
          This method returns the distribution in R notation.
 int getSizeOfEventSpaceForRandomVariablesOfParameter(int index)
          Returns the size of the event space of the random variables that are affected by parameter no.
abstract  void initializeUniformly()
          This method set special parameters that lead to an uniform distribution.
 boolean isPossible(int... positions)
          This method returns true if the given positions are in the domain of the PositionDiffSM.
 void modify(int delta)
          This method modifies the underlying AlphabetContainer.
 boolean next()
          This method steps to the next reasonable outcome if possible.
 void reset()
          This method resets the iterator to the initial state (first reasonable output) so that it can be used again.
 String toString(NumberFormat nf)
          This method returns a String representation of the instance.
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.differentiable.mixture.motif.PositionDiffSM
clone, getInternalPosition, getLogScore, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivationForInternal, getLogScoreFor, getLogScoreForInternal, getValuesFromSequence
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractDifferentiableStatisticalModel
emitDataSet, getInitialClassParam, getLogProbFor, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getMaximalMarkovOrder, isNormalized, isNormalized
 
Methods inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
getAlphabetContainer, getCharacteristics, getLength, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreFor, 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.DifferentiableStatisticalModel
addGradientOfLogPriorTerm, getLogPriorTerm
 
Methods inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
getCurrentParameterValues, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, setParameters
 
Methods inherited from interface de.jstacs.sequenceScores.SequenceScore
getAlphabetContainer, getCharacteristics, getInstanceName, getLength, getLogScoreFor, getLogScoreFor, getNumericalCharacteristics, isInitialized
 

Field Detail

ess

protected double ess
The equivalent sample size.


min

protected int min
The minimal value.


max

protected int max
The maximal value.


delta

protected int delta
The difference of maximal and minimal value.

Constructor Detail

DurationDiffSM

protected DurationDiffSM(int min,
                         int max,
                         double ess)
The default constructor.

Parameters:
min - the minimal value
max - the maximal value
ess - the equivalent sample size

DurationDiffSM

protected DurationDiffSM(StringBuffer source)
                  throws NonParsableException
This is the constructor for Storable. Creates a new DurationDiffSM out of a StringBuffer.

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

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML representation as StringBuffer of an instance of the implementing class.

Specified by:
toXML in interface Storable
Overrides:
toXML in class PositionDiffSM
Returns:
the XML representation

fromXML

protected void fromXML(StringBuffer xml)
                throws NonParsableException
Description copied from class: AbstractDifferentiableSequenceScore
This method is called in the constructor for the Storable interface to create a scoring function from a StringBuffer.

Overrides:
fromXML in class PositionDiffSM
Parameters:
xml - the XML representation as StringBuffer
Throws:
NonParsableException - if the StringBuffer could not be parsed
See Also:
AbstractDifferentiableSequenceScore.AbstractDifferentiableSequenceScore(StringBuffer)

reset

public void reset()
Description copied from class: PositionDiffSM
This method resets the iterator to the initial state (first reasonable output) so that it can be used again.

Specified by:
reset in class PositionDiffSM

next

public boolean next()
Description copied from class: PositionDiffSM
This method steps to the next reasonable outcome if possible.

Specified by:
next in class PositionDiffSM
Returns:
true if a next reasonable outcome could be set, otherwise false

getSizeOfEventSpaceForRandomVariablesOfParameter

public int getSizeOfEventSpaceForRandomVariablesOfParameter(int index)
Description copied from interface: DifferentiableStatisticalModel
Returns the size of the event space of the random variables that are affected by parameter no. index, i.e. the product of the sizes of the alphabets at the position of each random variable affected by parameter index. For DNA alphabets this corresponds to 4 for a PWM, 16 for a WAM except position 0, ...

Parameters:
index - the index of the parameter
Returns:
the size of the event space

getESS

public final double getESS()
Description copied from interface: DifferentiableStatisticalModel
Returns the equivalent sample size (ess) of this model, i.e. the equivalent sample size for the class or component that is represented by this model.

Returns:
the equivalent sample size.

isPossible

public boolean isPossible(int... positions)
Description copied from class: PositionDiffSM
This method returns true if the given positions are in the domain of the PositionDiffSM.

Specified by:
isPossible in class PositionDiffSM
Parameters:
positions - the positions to be tested
Returns:
true if the given positions are in the domain of the PositionDiffSM

getMin

public final int getMin()
Returns the minimal value that can be scored.

Returns:
the minimal value that can be scored.

getMax

public final int getMax()
Returns the maximal value that can be scored.

Returns:
the maximal value that can be scored.

getNumberOfPossibilities

public int getNumberOfPossibilities()
Returns the number of different possibilities that can be scored.

Returns:
the number of different possibilities that can be scored.

initializeUniformly

public abstract void initializeUniformly()
This method set special parameters that lead to an uniform distribution.


adjust

public abstract void adjust(int[] length,
                            double[] weight)
This method adjust the parameter based on the given statistic.

Parameters:
length - an array containing length values
weight - an array containing corresponding weight values

modify

public void modify(int delta)
This method modifies the underlying AlphabetContainer. This might be necessary if the motif length changed.

Parameters:
delta - the change
See Also:
Mutable.modify(int, int), MutableMotifDiscoverer.modifyMotif(int, int, int)

getLogNormalizationConstant

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

Returns:
the logarithm of the normalization constant Z

getLogPartialNormalizationConstant

public final 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}}\]
.

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()

getRNotation

protected abstract String getRNotation(String distributionName,
                                       NumberFormat nf)
This method returns the distribution in R notation.

Parameters:
distributionName - the name of the distribution, e.g., "p"
nf - the NumberFormat to be used, can be null
Returns:
the distribution in R notation
See Also:
REnvironment

toString

public String toString(NumberFormat nf)
Description copied from interface: SequenceScore
This method returns a String representation of the instance.

Parameters:
nf - the NumberFormat for the String representation of parameters or probabilities
Returns:
a String representation of the instance