de.jstacs.models.discrete.inhomogeneous
Class MEMConstraint

java.lang.Object
  extended by de.jstacs.models.discrete.Constraint
      extended by de.jstacs.models.discrete.inhomogeneous.InhConstraint
          extended by de.jstacs.models.discrete.inhomogeneous.MEMConstraint
All Implemented Interfaces:
Storable, Cloneable

public class MEMConstraint
extends InhConstraint

The constraint can be used for any MEM application.

Author:
Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.models.discrete.inhomogeneous.InhConstraint
offset
 
Fields inherited from class de.jstacs.models.discrete.Constraint
counts, freq, usedPositions
 
Constructor Summary
MEMConstraint(int[] pos, int[] alphabetLength)
          Creates a MEMConstraint as part of a (whole) model
MEMConstraint(int[] pos, int[] alphabetLength, int[] corrected_positions)
          Creates a MEMConstraint as part of a model
MEMConstraint(StringBuffer xml)
          Creates a MEMConstraint from a StringBuffer
 
Method Summary
protected  void appendAdditionalInfo(StringBuffer xml)
          This method appends additional information that are not stored in the base class to the StringBuffer.
 MEMConstraint clone()
           
 void estimate(double ess)
          Estimates the (smoothed) relative frequencies using the ess.
protected  void extractAdditionalInfo(StringBuffer xml)
          This method parses additional information from the StringBuffer that are not parsed in the base class.
 int getCorrectedPosition(int index)
          Returns the value of the corrected position
 double getExpLambda(int index)
          Returns \exp(\lambda_{index}).
 double getFreq(int index)
          Returns the current frequency with index index
 double getLambda(int index)
          Returns \lambda_{index}.
protected  String getXMLTag()
          Returns the XML-tag that is used for the class to en- or decode.
 void multiplyExpLambdaWith(int index, double val)
          Multiplies \exp(\lambda_{index}) with val
 void reset()
          This method resets all member variables the are in someway counters, frequencies, ...
 int satisfiesSpecificConstraint(SequenceIterator sequence)
          Returns the index of that constraint that is satiesfied by sequence
 void setExpLambda(int index, double val)
          Sets the value of exp(\lambda_{index})
 void setLambda(int index, double val)
          Sets the value of \lambda_{index}
 String toString()
           
 
Methods inherited from class de.jstacs.models.discrete.inhomogeneous.InhConstraint
satisfiesSpecificConstraint
 
Methods inherited from class de.jstacs.models.discrete.Constraint
add, add, estimateUnConditional, getCount, getFreq, getMarginalOrder, getNumberOfSpecificConstraints, getPosition, getPositions, toXML
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MEMConstraint

public MEMConstraint(int[] pos,
                     int[] alphabetLength)
              throws IllegalArgumentException
Creates a MEMConstraint as part of a (whole) model

Parameters:
pos - the used positions (have to be sorted)
alphabetLength - an array containing the length of the the alphabet for each position (of the whole model)
Throws:
IllegalArgumentException - if pos is not sorted

MEMConstraint

public MEMConstraint(int[] pos,
                     int[] alphabetLength,
                     int[] corrected_positions)
              throws IllegalArgumentException
Creates a MEMConstraint as part of a model

Parameters:
pos - the used positions (have to be sorted)
alphabetLength - an array containing the length of the the alphabet for each position (of the whole model)
corrected_positions - an array containing the corrected positions
Throws:
IllegalArgumentException - if pos is not sorted or pos.length!=corrected_positions.length

MEMConstraint

public MEMConstraint(StringBuffer xml)
              throws NonParsableException
Creates a MEMConstraint from a StringBuffer

Parameters:
xml - the buffer
Throws:
NonParsableException - if the buffer is not parsable
Method Detail

clone

public MEMConstraint clone()
                    throws CloneNotSupportedException
Overrides:
clone in class InhConstraint
Throws:
CloneNotSupportedException

estimate

public void estimate(double ess)
Description copied from class: Constraint
Estimates the (smoothed) relative frequencies using the ess.

Specified by:
estimate in class Constraint
Parameters:
ess - the ESS

getCorrectedPosition

public int getCorrectedPosition(int index)
Returns the value of the corrected position

Parameters:
index -
Returns:
the value of the corrected position

getExpLambda

public double getExpLambda(int index)
Returns \exp(\lambda_{index}).

Parameters:
index - the index
Returns:
\exp(\lambda_{index})

getLambda

public double getLambda(int index)
Returns \lambda_{index}.

Parameters:
index - the index
Returns:
\lambda_{index}

multiplyExpLambdaWith

public void multiplyExpLambdaWith(int index,
                                  double val)
Multiplies \exp(\lambda_{index}) with val

Parameters:
index - the index
val - the factor/value

reset

public void reset()
Description copied from class: Constraint
This method resets all member variables the are in someway counters, frequencies, ...

Overrides:
reset in class Constraint

satisfiesSpecificConstraint

public int satisfiesSpecificConstraint(SequenceIterator sequence)
Returns the index of that constraint that is satiesfied by sequence

Parameters:
sequence - the SequenceIterator
Returns:
the index of the fulfilled constraint

getFreq

public double getFreq(int index)
Description copied from class: Constraint
Returns the current frequency with index index

Overrides:
getFreq in class Constraint
Parameters:
index - the index
Returns:
the current frequency

setExpLambda

public void setExpLambda(int index,
                         double val)
Sets the value of exp(\lambda_{index})

Parameters:
index - the index
val - the value

setLambda

public void setLambda(int index,
                      double val)
Sets the value of \lambda_{index}

Parameters:
index - the index
val - the value

toString

public String toString()
Specified by:
toString in class Constraint

appendAdditionalInfo

protected void appendAdditionalInfo(StringBuffer xml)
Description copied from class: Constraint
This method appends additional information that are not stored in the base class to the StringBuffer.

Overrides:
appendAdditionalInfo in class InhConstraint
Parameters:
xml - the StringBuffer that is used for appending additional information

getXMLTag

protected String getXMLTag()
Description copied from class: Constraint
Returns the XML-tag that is used for the class to en- or decode.

Specified by:
getXMLTag in class Constraint
Returns:
the XML-tag that is used for the class to en- or decode

extractAdditionalInfo

protected void extractAdditionalInfo(StringBuffer xml)
                              throws NonParsableException
Description copied from class: Constraint
This method parses additional information from the StringBuffer that are not parsed in the base class.

Overrides:
extractAdditionalInfo in class InhConstraint
Parameters:
xml - the StringBuffer to parse
Throws:
NonParsableException - if something with the parsing went wrong