|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.models.discrete.Constraint
public abstract class Constraint
The main class for all constraints on models. This class centralizes all specific constraints (e.g. P(X1=A,X2=A)) from a partitioning constraint (e.g. all specific constraints for some given positions).
Field Summary | |
---|---|
protected double[] |
counts
The counts for each specific constraint. |
protected double[] |
freq
The frequencies estimated from the counts. |
protected int[] |
usedPositions
The used positions. |
Constructor Summary | |
---|---|
Constraint(int[] usedPositions,
int n)
The main constructor. |
|
Constraint(StringBuffer xml)
The standard constructor for the interface Storable . |
Method Summary | |
---|---|
void |
add(int index,
double weight)
Adds the given weight to the count with index
index . |
void |
add(Sequence seq,
int start,
double weight)
This method determines the specific constraint that is fulfilled by the Sequence seq and adds the weight to the
specific counter. |
protected abstract void |
appendAdditionalInfo(StringBuffer xml)
This method appends additional information that is not stored in the base class to the StringBuffer . |
protected Constraint |
clone()
|
abstract void |
estimate(double ess)
Estimates the (smoothed) relative frequencies using the ess (equivalent sample size). |
protected void |
estimateUnConditional(int start,
int end,
double pc,
boolean exceptionWhenNoData)
Estimates unconditionally. |
protected abstract void |
extractAdditionalInfo(StringBuffer xml)
This method parses additional information from the StringBuffer
that is not parsed in the base class. |
double |
getCount(int index)
Returns the current count with index index . |
double |
getFreq(int index)
Returns the current frequency with index index . |
double |
getFreq(Sequence seq,
int start)
This method determines the specific constraint that is fulfilled by the Sequence seq beginning at position
start . |
int |
getMarginalOrder()
Returns the marginal order, i.e. the number of used random variables. |
int |
getNumberOfSpecificConstraints()
Returns the number of specific constraints. |
int |
getPosition(int index)
Returns the position with index index . |
int[] |
getPositions()
Returns a clone of the array of used positions. |
protected abstract String |
getXMLTag()
Returns the XML tag that is used for the class to en- or decode. |
void |
reset()
This method resets all member variables that are in some way counters, frequencies, ... |
abstract int |
satisfiesSpecificConstraint(Sequence seq,
int start)
This method returns the index of the specific constraint that is fulfilled by the Sequence seq beginning at position
start . |
abstract String |
toString()
|
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double[] counts
protected double[] freq
protected int[] usedPositions
Constructor Detail |
---|
public Constraint(int[] usedPositions, int n) throws IllegalArgumentException
Constraint
and checks that
each position is used maximally once.
usedPositions
- the used positions (will be cloned), have to be non-negativen
- the number of specific constraints
IllegalArgumentException
- if there are some fundamental errors in the arguments for the positionspublic Constraint(StringBuffer xml) throws NonParsableException
Storable
.
Creates a new Constraint
out of its XML representation.
xml
- the XML representation as StringBuffer
NonParsableException
- if the Constraint
could not be reconstructed out of
the XML representation (the StringBuffer
could not be
parsed)Storable
,
extractAdditionalInfo(StringBuffer)
Method Detail |
---|
public final void add(int index, double weight)
weight
to the count with index
index
.
index
- the indexweight
- the weightpublic void add(Sequence seq, int start, double weight)
Sequence
seq
and adds the weight
to the
specific counter.
seq
- the sequencestart
- the start positionweight
- the weight for the sequencesatisfiesSpecificConstraint(Sequence, int)
,
add(int, double)
protected Constraint clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public abstract void estimate(double ess)
ess
- the essprotected void estimateUnConditional(int start, int end, double pc, boolean exceptionWhenNoData)
start
- the start indexend
- the end indexpc
- the pseudocount for each parameterexceptionWhenNoData
- indicates if an (runtime) exception is thrown if no data was
available to estimate the parametersprotected abstract void appendAdditionalInfo(StringBuffer xml)
StringBuffer
.
xml
- the StringBuffer
that is used for appending additional
informationpublic double getCount(int index)
index
.
index
- the index
public double getFreq(int index)
index
.
index
- the index
public double getFreq(Sequence seq, int start)
Sequence
seq
beginning at position
start
.
seq
- the Sequence
start
- the start position
satisfiesSpecificConstraint(Sequence, int)
,
getFreq(int)
public int getMarginalOrder()
public int getNumberOfSpecificConstraints()
public int getPosition(int index)
index
.
index
- the index
index
public int[] getPositions()
protected abstract String getXMLTag()
public void reset()
public abstract int satisfiesSpecificConstraint(Sequence seq, int start)
Sequence
seq
beginning at position
start
.
seq
- the sequencestart
- the start position
protected abstract void extractAdditionalInfo(StringBuffer xml) throws NonParsableException
StringBuffer
that is not parsed in the base class.
xml
- the StringBuffer
to be parsed
NonParsableException
- if something with the parsing went wrongpublic abstract String toString()
toString
in class Object
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.
toXML
in interface Storable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |