de.jstacs.models.discrete.homogeneous
Class HomogeneousModel.HomCondProb

java.lang.Object
  extended by de.jstacs.models.discrete.Constraint
      extended by de.jstacs.models.discrete.homogeneous.HomogeneousModel.HomCondProb
All Implemented Interfaces:
Storable
Enclosing class:
HomogeneousModel

protected class HomogeneousModel.HomCondProb
extends Constraint

This class handles the (conditional) homogeneous probabilities in a fast way.

Author:
Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.models.discrete.Constraint
counts, freq, usedPositions
 
Constructor Summary
HomogeneousModel.HomCondProb(HomogeneousModel.HomCondProb old)
          This constructor is used for cloning instances, since any instance is an inner instance of a HomogeneousModel.
HomogeneousModel.HomCondProb(int[] pos, int n)
          The main constructor.
HomogeneousModel.HomCondProb(StringBuffer xml)
          Creates an instance from a StringBuffer (see Storable).
 
Method Summary
protected  void appendAdditionalInfo(StringBuffer xml)
          This method appends additional information that are not stored in the base class to the StringBuffer.
 void estimate(double ess)
          Estimates the (smoothed) relative frequencies using the ess.
protected  void estimateUnConditional(int start, int end, double pc, boolean exceptionWhenNoData)
          Estimates unconditionally.
protected  void extractAdditionalInfo(StringBuffer xml)
          This method parses additional information from the StringBuffer that are not parsed in the base class.
 double getLnFreq(int index)
          Returns the logarithmic frequency.
protected  String getXMLTag()
          Returns the XML-tag that is used for the class to en- or decode.
 int satisfiesSpecificConstraint(Sequence seq, int start)
          This method returns the index of the specific constraint that is fullfilled by the sequence beginning at start.
 String toString()
           
 
Methods inherited from class de.jstacs.models.discrete.Constraint
add, add, clone, getCount, getFreq, getFreq, getMarginalOrder, getNumberOfSpecificConstraints, getPosition, getPositions, reset, toXML
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HomogeneousModel.HomCondProb

public HomogeneousModel.HomCondProb(int[] pos,
                                    int n)
The main constructor. Checks that each position is used maximally once.

Parameters:
pos - the used positions (will be cloned), has to be non-negative
n - the number of specific constraints

HomogeneousModel.HomCondProb

public HomogeneousModel.HomCondProb(StringBuffer xml)
                             throws NonParsableException
Creates an instance from a StringBuffer (see Storable).

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

HomogeneousModel.HomCondProb

public HomogeneousModel.HomCondProb(HomogeneousModel.HomCondProb old)
This constructor is used for cloning instances, since any instance is an inner instance of a HomogeneousModel.

Parameters:
old - the old instance to be cloned
Method Detail

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

getLnFreq

public double getLnFreq(int index)
Returns the logarithmic frequency.

Parameters:
index - the index
Returns:
the logarithmic frequency

satisfiesSpecificConstraint

public int satisfiesSpecificConstraint(Sequence seq,
                                       int start)
Description copied from class: Constraint
This method returns the index of the specific constraint that is fullfilled by the sequence beginning at start.

Specified by:
satisfiesSpecificConstraint in class Constraint
Parameters:
seq - the sequence
start - the start position
Returns:
the index of the fulfilled, specific constraint

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.

Specified by:
appendAdditionalInfo in class Constraint
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

estimateUnConditional

protected void estimateUnConditional(int start,
                                     int end,
                                     double pc,
                                     boolean exceptionWhenNoData)
Description copied from class: Constraint
Estimates unconditionally.

Overrides:
estimateUnConditional in class Constraint
Parameters:
start - the start index
end - the end index
pc - the pseudocount for each parameter
exceptionWhenNoData - if true an (runtime) exception is thrown if no data was available to estimate the parameters

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.

Specified by:
extractAdditionalInfo in class Constraint
Parameters:
xml - the StringBuffer to parse
Throws:
NonParsableException - if something with the parsing went wrong