public class UniformEmission extends Object implements DifferentiableEmission
| Constructor and Description |
|---|
UniformEmission(AlphabetContainer con)
The main constructor for a
UniformEmission. |
UniformEmission(StringBuffer xml)
The standard constructor for the interface
Storable. |
| Modifier and Type | Method and Description |
|---|---|
void |
addGradientOfLogPriorTerm(double[] grad,
int offset)
This method computes the gradient of
Emission.getLogPriorTerm() for each
parameter of this model. |
void |
addToStatistic(boolean forward,
int startPos,
int endPos,
double weight,
Sequence seq)
This method adds the
weight to the internal sufficient statistic. |
UniformEmission |
clone() |
void |
estimateFromStatistic()
This method estimates the parameters from the internal sufficient statistic.
|
void |
fillCurrentParameter(double[] params)
Fills the current parameters in the global code>params array using the internal offset.
|
void |
fillSamplingGroups(int parameterOffset,
LinkedList<int[]> list)
Adds the groups of indexes of those parameters of this emission that should be sampled
together in one step of a grouped sampling procedure, each as an
int[], into list. |
AlphabetContainer |
getAlphabetContainer()
This method returns the
AlphabetContainer of this emission. |
double |
getLogPriorTerm()
Returns a value that is proportional to the log of the prior.
|
double |
getLogProbAndPartialDerivationFor(boolean forward,
int startPos,
int endPos,
IntList indices,
DoubleList partDer,
Sequence seq)
|
double |
getLogProbFor(boolean forward,
int startPos,
int endPos,
Sequence seq)
This method computes the logarithm of the likelihood.
|
String |
getNodeLabel(double weight,
String name,
NumberFormat nf)
Returns the graphviz label of the node containing this emission.
|
String |
getNodeShape(boolean forward)
Returns the graphviz string for the shape of the node.
|
int |
getNumberOfParameters()
Returns the number of parameters of this emission.
|
int |
getSizeOfEventSpace()
Returns the size of the event space, i.e., the number of possible outcomes,
for the random variables of this emission
|
void |
initializeFunctionRandomly()
This method initializes the emission randomly.
|
void |
joinStatistics(Emission... emissions)
This method joins the statistics of different instances and sets this joined statistic as statistic of each instance.
|
void |
resetStatistic()
This method resets the internal sufficient statistic.
|
void |
setParameter(double[] params,
int offset)
This method sets the internal parameters using the given global parameter array, the global offset of the HMM and the internal offset.
|
int |
setParameterOffset(int offset)
This method sets the internal parameter offset and returns the new parameter offset for further use.
|
void |
setParameters(Emission t)
Set values of parameters of the instance to the value of the parameters of the given instance.
|
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. |
public UniformEmission(AlphabetContainer con)
UniformEmission.con - the AlphabetContainer for this emissionpublic UniformEmission(StringBuffer xml) throws NonParsableException
Storable.
Constructs a UniformEmission out of an XML representation.xml - the XML representation as StringBufferNonParsableException - if the UniformEmission could not be reconstructed out of
the StringBuffer xmlpublic UniformEmission clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic void addToStatistic(boolean forward,
int startPos,
int endPos,
double weight,
Sequence seq)
throws OperationNotSupportedException
Emissionweight to the internal sufficient statistic.addToStatistic in interface Emissionforward - whether to use the forward or the reverse strandstartPos - the start positionendPos - the end positionweight - the weight of the sequenceseq - the sequenceOperationNotSupportedException - if forward=false and the reverse complement of the sequence seq is not definedpublic void estimateFromStatistic()
EmissionestimateFromStatistic in interface Emissionpublic AlphabetContainer getAlphabetContainer()
EmissionAlphabetContainer of this emission.getAlphabetContainer in interface EmissionAlphabetContainer of this emissionpublic double getLogPriorTerm()
EmissiongetLogPriorTerm in interface EmissionStatisticalModel.getLogPriorTerm()public double getLogProbFor(boolean forward,
int startPos,
int endPos,
Sequence seq)
throws OperationNotSupportedException
EmissiongetLogProbFor in interface Emissionforward - whether to use the forward or the reverse strandstartPos - the start positionendPos - the end positionseq - the sequenceOperationNotSupportedException - if forward=false and the reverse complement of the sequence seq is not definedpublic String getNodeLabel(double weight, String name, NumberFormat nf)
EmissiongetNodeLabel in interface Emissionweight - the weight of the node which is represented by
the color of the node, or -1 for no representation, i.e.,
white backgroundname - the name of the state using this emissionnf - the NumberFormat for formatting the textual representation of this emissionpublic String getNodeShape(boolean forward)
EmissiongetNodeShape in interface Emissionforward - if this emission is used on the forward strandpublic void initializeFunctionRandomly()
EmissioninitializeFunctionRandomly in interface Emissionpublic void joinStatistics(Emission... emissions)
EmissionjoinStatistics in interface Emissionemissions - the emissions to be joinedpublic void resetStatistic()
EmissionresetStatistic in interface Emissionpublic StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.public void addGradientOfLogPriorTerm(double[] grad,
int offset)
DifferentiableEmissionEmission.getLogPriorTerm() for each
parameter of this model. The results are added to the array
grad beginning at index (offset + internal offset).addGradientOfLogPriorTerm in interface DifferentiableEmissiongrad - the array of gradientsoffset - the start index of the HMM in the grad array, where the
partial derivations for the parameters of the HMM shall be
enteredEmission.getLogPriorTerm(),
DifferentiableEmission.setParameterOffset(int)public void fillCurrentParameter(double[] params)
DifferentiableEmissionfillCurrentParameter in interface DifferentiableEmissionparams - the global parameter array of the HMMDifferentiableEmission.setParameterOffset(int)public void fillSamplingGroups(int parameterOffset,
LinkedList<int[]> list)
DifferentiableEmissionint[], into list.
In most cases, one group should contain the parameters that are living on a common simplex.
The internal indexes of the parameters are incremeneted by an external parameterOffsetfillSamplingGroups in interface DifferentiableEmissionparameterOffset - the external parameter offsetlist - the list of sampling groupspublic double getLogProbAndPartialDerivationFor(boolean forward,
int startPos,
int endPos,
IntList indices,
DoubleList partDer,
Sequence seq)
throws OperationNotSupportedException
DifferentiableEmissionSequence beginning at
position start in the Sequence and fills lists with
the indices and the partial derivations.getLogProbAndPartialDerivationFor in interface DifferentiableEmissionforward - a switch whether to use the forward or the reverse complementary strand of the sequencestartPos - the start position in the SequenceendPos - the end position in the Sequenceindices - an IntList of indices, after method invocation the
list should contain the indices i where
is not zeropartDer - a DoubleList of partial derivations, after method
invocation the list should contain the corresponding
that are not zeroseq - the SequenceSequenceOperationNotSupportedException - if forward==false and the reverse complement of the sequence can not be computedpublic int getNumberOfParameters()
DifferentiableEmissiongetNumberOfParameters in interface DifferentiableEmissionpublic int getSizeOfEventSpace()
DifferentiableEmissiongetSizeOfEventSpace in interface DifferentiableEmissionpublic void setParameter(double[] params,
int offset)
DifferentiableEmissionsetParameter in interface DifferentiableEmissionparams - the global parameter array of the classifieroffset - the offset of the HMMDifferentiableEmission.setParameterOffset(int)public int setParameterOffset(int offset)
DifferentiableEmissionsetParameterOffset in interface DifferentiableEmissionoffset - the offset to be setpublic void setParameters(Emission t) throws IllegalArgumentException
EmissionsetParameters in interface Emissiont - the emission with the parameters to be setIllegalArgumentException - if the assumption about the same class for given and current instance is wrongpublic String toString(NumberFormat nf)
EmissionString representation of the instance.toString in interface Emissionnf - the NumberFormat for the String representation of parameters or probabilitiesString representation of the instance