de.jstacs.scoringFunctions.mix.motifSearch
Class DurationScoringFunction

java.lang.Object
  extended by de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
      extended by de.jstacs.scoringFunctions.mix.motifSearch.PositionScoringFunction
          extended by de.jstacs.scoringFunctions.mix.motifSearch.DurationScoringFunction
All Implemented Interfaces:
NormalizableScoringFunction, ScoringFunction, Storable, Cloneable
Direct Known Subclasses:
MixtureDuration, SkewNormalLikeScoringFunction, UniformDurationScoringFunction

public abstract class DurationScoringFunction
extends PositionScoringFunction

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:
HiddenMotifsMixture

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.scoringFunctions.mix.motifSearch.PositionScoringFunction
internal
 
Fields inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
alphabets, length, r
 
Fields inherited from interface de.jstacs.scoringFunctions.ScoringFunction
UNKNOWN
 
Constructor Summary
protected DurationScoringFunction(int min, int max, double ess)
          The default constructor.
protected DurationScoringFunction(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. the equivalent sample size for the class or component that is represented by this model.
 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)
          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 PositionScoringFunction.
 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()
           
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 
Methods inherited from class de.jstacs.scoringFunctions.mix.motifSearch.PositionScoringFunction
clone, getInternalPosition, getLogScore, getLogScore, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivationForInternal, getLogScoreForInternal, getValuesFromSequence
 
Methods inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
getAlphabetContainer, getInitialClassParam, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfRecommendedStarts, getNumberOfStarts, isNormalized, 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, getLogPriorTerm
 
Methods inherited from interface de.jstacs.scoringFunctions.ScoringFunction
getCurrentParameterValues, getInstanceName, getNumberOfParameters, initializeFunction, initializeFunctionRandomly, isInitialized, setParameters
 

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

DurationScoringFunction

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

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

DurationScoringFunction

protected DurationScoringFunction(StringBuffer source)
                           throws NonParsableException
This is the constructor for Storable. Creates a new DurationScoringFunction 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 PositionScoringFunction
Returns:
the XML representation

fromXML

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

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

reset

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

Specified by:
reset in class PositionScoringFunction

next

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

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

getSizeOfEventSpaceForRandomVariablesOfParameter

public int getSizeOfEventSpaceForRandomVariablesOfParameter(int index)
Description copied from interface: NormalizableScoringFunction
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: NormalizableScoringFunction
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: PositionScoringFunction
This method returns true if the given positions are in the domain of the PositionScoringFunction.

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

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: NormalizableScoringFunction
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: 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}}\]
.

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

getRNotation

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

Parameters:
distributionName - the name of the distribution, e.g., "p"
Returns:
the distribution in R notation
See Also:
REnvironment

toString

public String toString()
Overrides:
toString in class Object