|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.sequenceScores.statisticalModels.trainable.hmm.states.emissions.continuous.GaussianEmission
public class GaussianEmission
Emission for continuous values following a Gaussian distribution. The Gaussian density is parameterized in terms of mean and (log) precision. The prior of the Gaussian density is a normal-gamma density parameterized in terms of shape and rate.
Constructor Summary | |
---|---|
GaussianEmission(AlphabetContainer con)
Creates a GaussianEmission which can be used for maximum likelihood. |
|
GaussianEmission(AlphabetContainer con,
double ess,
double priorMu,
double priorAlpha,
double priorBeta,
boolean transformed)
Creates a GaussianEmission with normal-gamma prior by directly defining the hyper-parameters of the prior. |
|
GaussianEmission(double ess,
AlphabetContainer con,
double priorMu,
double expectedPrecision,
double sdPrecision,
boolean transformed)
Creates a GaussianEmission with normal-gamma prior by defining the expected precision and the expected standard deviation of the precision, i.e. via the
expectation and variance of the gamma part of the normal-gamma prior. |
|
GaussianEmission(StringBuffer xml)
Creates a GaussianEmission from its XML representation. |
Method Summary | |
---|---|
void |
addGradientOfLogPriorTerm(double[] gradient,
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. |
GaussianEmission |
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 . |
protected void |
fromXML(StringBuffer xml)
This method is internally used by the constructor GaussianEmission(StringBuffer) . |
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)
Returns the logarithmic score for a Sequence beginning at
position start in the Sequence and fills lists with
the indices and the partial derivations. |
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. |
protected void |
precompute()
This method precomputes some normalization constant. |
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()
|
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 |
Constructor Detail |
---|
public GaussianEmission(AlphabetContainer con)
GaussianEmission
which can be used for maximum likelihood.
con
- the alphabet of the emissionspublic GaussianEmission(AlphabetContainer con, double ess, double priorMu, double priorAlpha, double priorBeta, boolean transformed)
GaussianEmission
with normal-gamma prior by directly defining the hyper-parameters of the prior.
con
- the alphabet of the emissionsess
- the equivalent sample size of the normal-gamma priorpriorMu
- the a-priori mean of the normal part of the priorpriorAlpha
- the shape parameter of the gamma part of the priorpriorBeta
- the rate parameter of the gamma part of the priortransformed
- use the transformed Gaussian density, i.e. exponential precision, ignored for numerical optimizationpublic GaussianEmission(double ess, AlphabetContainer con, double priorMu, double expectedPrecision, double sdPrecision, boolean transformed)
GaussianEmission
with normal-gamma prior by defining the expected precision and the expected standard deviation of the precision, i.e. via the
expectation and variance of the gamma part of the normal-gamma prior.
ess
- the equivalent sample size of the normal-gamma priorcon
- the alphabet of the emissionspriorMu
- the a-priori mean of the normal part of the priorexpectedPrecision
- the expected value of the precisionsdPrecision
- the expected standard deviation of the precisiontransformed
- use the transformed Gaussian density, i.e. exponential precision, ignored for numerical optimizationpublic GaussianEmission(StringBuffer xml) throws NonParsableException
GaussianEmission
from its XML representation.
xml
- the XML representation.
NonParsableException
- if the XML representation could not be parsedMethod Detail |
---|
public GaussianEmission clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public void addGradientOfLogPriorTerm(double[] gradient, int offset)
DifferentiableEmission
Emission.getLogPriorTerm()
for each
parameter of this model. The results are added to the array
grad
beginning at index (offset
+ internal offset).
addGradientOfLogPriorTerm
in interface DifferentiableEmission
gradient
- 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 joinStatistics(Emission... emissions)
Emission
joinStatistics
in interface Emission
emissions
- the emissions to be joinedpublic void addToStatistic(boolean forward, int startPos, int endPos, double weight, Sequence seq) throws OperationNotSupportedException
Emission
weight
to the internal sufficient statistic.
addToStatistic
in interface Emission
forward
- whether to use the forward or the reverse strandstartPos
- the start positionendPos
- the end positionweight
- the weight of the sequenceseq
- the sequence
OperationNotSupportedException
- if forward=false
and the reverse complement of the sequence seq
is not definedpublic void estimateFromStatistic()
Emission
estimateFromStatistic
in interface Emission
public void fillCurrentParameter(double[] params)
DifferentiableEmission
fillCurrentParameter
in interface DifferentiableEmission
params
- the global parameter array of the HMMDifferentiableEmission.setParameterOffset(int)
public void setParameter(double[] params, int offset)
DifferentiableEmission
setParameter
in interface DifferentiableEmission
params
- the global parameter array of the classifieroffset
- the offset of the HMMDifferentiableEmission.setParameterOffset(int)
public int setParameterOffset(int offset)
DifferentiableEmission
setParameterOffset
in interface DifferentiableEmission
offset
- the offset to be set
protected void fromXML(StringBuffer xml) throws NonParsableException
GaussianEmission(StringBuffer)
.
xml
- the StringBuffer
containing the xml representation of an instance
NonParsableException
- if the StringBuffer
is not parsableGaussianEmission(StringBuffer)
public double getLogPriorTerm()
Emission
getLogPriorTerm
in interface Emission
StatisticalModel.getLogPriorTerm()
public double getLogProbAndPartialDerivationFor(boolean forward, int startPos, int endPos, IntList indices, DoubleList partDer, Sequence seq) throws OperationNotSupportedException
DifferentiableEmission
Sequence
beginning at
position start
in the Sequence
and fills lists with
the indices and the partial derivations.
getLogProbAndPartialDerivationFor
in interface DifferentiableEmission
forward
- a switch whether to use the forward or the reverse complementary strand of the sequencestartPos
- the start position in the Sequence
endPos
- the end position in the Sequence
indices
- an IntList
of indices, after method invocation the
list should contain the indices i where
partDer
- a DoubleList
of partial derivations, after method
invocation the list should contain the corresponding
seq
- the Sequence
Sequence
OperationNotSupportedException
- if forward==false
and the reverse complement of the sequence can not be computedpublic double getLogProbFor(boolean forward, int startPos, int endPos, Sequence seq) throws OperationNotSupportedException
Emission
getLogProbFor
in interface Emission
forward
- whether to use the forward or the reverse strandstartPos
- the start positionendPos
- the end positionseq
- the sequence
OperationNotSupportedException
- if forward=false
and the reverse complement of the sequence seq
is not definedpublic void initializeFunctionRandomly()
Emission
initializeFunctionRandomly
in interface Emission
protected void precompute()
public void resetStatistic()
Emission
resetStatistic
in interface Emission
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.
toXML
in interface Storable
public AlphabetContainer getAlphabetContainer()
Emission
AlphabetContainer
of this emission.
getAlphabetContainer
in interface Emission
AlphabetContainer
of this emissionpublic String toString()
toString
in class Object
public String getNodeShape(boolean forward)
Emission
getNodeShape
in interface Emission
forward
- if this emission is used on the forward strand
public String getNodeLabel(double weight, String name, NumberFormat nf)
Emission
getNodeLabel
in interface Emission
weight
- 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 emission
public void fillSamplingGroups(int parameterOffset, LinkedList<int[]> list)
DifferentiableEmission
int[]
, 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 parameterOffset
fillSamplingGroups
in interface DifferentiableEmission
parameterOffset
- the external parameter offsetlist
- the list of sampling groupspublic int getNumberOfParameters()
DifferentiableEmission
getNumberOfParameters
in interface DifferentiableEmission
public int getSizeOfEventSpace()
DifferentiableEmission
getSizeOfEventSpace
in interface DifferentiableEmission
public void setParameters(Emission t) throws IllegalArgumentException
Emission
setParameters
in interface Emission
t
- the emission with the parameters to be set
IllegalArgumentException
- if the assumption about the same class for given and current instance is wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |