public class SimpleSamplingState extends SimpleState implements SamplingState
e, forward, name
Constructor and Description |
---|
SimpleSamplingState(SamplingEmission e,
String name,
boolean forward)
This constructor creates a state that can be used in a HMM that obtains its parameters from sampling.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptParameters()
This methods accepts the drawn parameters.
|
void |
drawParametersFromStatistic()
This method draws the parameters using a sufficient statistic representing a posteriori
density.
|
void |
extendSampling(int sampling,
boolean append)
This method allows to extend a sampling.
|
double |
getLogGammaScoreForCurrentStatistic()
This method calculates a score for the current statistics, which is independent from the current parameters
In general the gamma-score is a product of gamma-functions parameterized with the current statistics
|
double |
getLogPosteriorFromStatistic()
This method calculates the a-posteriori probability for the current statistics
|
void |
initForSampling(int starts)
This method initializes the instance for the sampling.
|
boolean |
isInSamplingMode()
This method returns
true if the object is currently used in
a sampling, otherwise false . |
boolean |
parseNextParameterSet()
This method allows the user to parse the next set of parameters (from a
file).
|
boolean |
parseParameterSet(int sampling,
int n)
This method allows the user to parse the set of parameters with index
n of a certain sampling (from a file). |
void |
samplingStopped()
This method is the opposite of the method
SamplingComponent.extendSampling(int, boolean) . |
addToStatistic, getGraphvizNodeOptions, getLogScoreFor, getName, isSilent, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addToStatistic
getGraphvizNodeOptions, getLogScoreFor, isSilent, toString
public SimpleSamplingState(SamplingEmission e, String name, boolean forward)
e
- the emissionname
- the name of the emission (e.g. for the Graphviz representation)forward
- a switch whether to use the forward or the reverse strandpublic void drawParametersFromStatistic() throws Exception
SamplingFromStatistic
SamplingComponent.acceptParameters()
so that they can later be parsed using the
methods of the interface.
SamplingComponent.initForSampling(int)
should be
called.drawParametersFromStatistic
in interface SamplingFromStatistic
Exception
- if there is a problem with drawing the parameters, the initialization, ...SamplingComponent.initForSampling(int)
,
SamplingComponent.acceptParameters()
public void extendSampling(int sampling, boolean append) throws IOException
SamplingComponent
extendSampling
in interface SamplingComponent
sampling
- the index of the samplingappend
- whether to append the sampled parameters to an existing file
or to overwrite the fileIOException
- if the file could not be handled correctlypublic void initForSampling(int starts) throws IOException
SamplingComponent
initForSampling
in interface SamplingComponent
starts
- the number of different sampling starts that will be doneIOException
- if something went wrongFile.createTempFile(String, String, java.io.File )
public boolean isInSamplingMode()
SamplingComponent
true
if the object is currently used in
a sampling, otherwise false
.isInSamplingMode
in interface SamplingComponent
true
if the object is currently used in a sampling,
otherwise false
public boolean parseNextParameterSet()
SamplingComponent
parseNextParameterSet
in interface SamplingComponent
true
if the parameters could be parsed, otherwise
false
SamplingComponent.parseParameterSet(int, int)
public boolean parseParameterSet(int sampling, int n) throws Exception
SamplingComponent
n
of a certain sampling
(from a file). The
internal numbering should start with 0. The parameter set with index 0 is
the initial (random) parameter set. It is recommended that a series of
parameter sets is accessed by the following lines:
for( sampling = 0; sampling < numSampling; sampling++ )
{
boolean b = parseParameterSet( sampling, n );
while( b )
{
//do something
b = parseNextParameterSet();
}
}
parseParameterSet
in interface SamplingComponent
sampling
- the index of the samplingn
- the index of the parameter settrue
if the parameter set could be parsedException
- if there is a problem with parsing the parametersSamplingComponent.parseNextParameterSet()
public void samplingStopped() throws IOException
SamplingComponent
SamplingComponent.extendSampling(int, boolean)
. It can be
used for closing any streams of writer, ...samplingStopped
in interface SamplingComponent
IOException
- if something went wrongSamplingComponent.extendSampling(int, boolean)
public void acceptParameters() throws IOException
SamplingComponent
acceptParameters
in interface SamplingComponent
IOException
- if the file could not be handled correctlypublic double getLogGammaScoreForCurrentStatistic()
SamplingState
getLogGammaScoreForCurrentStatistic
in interface SamplingState
public double getLogPosteriorFromStatistic()
SamplingFromStatistic
getLogPosteriorFromStatistic
in interface SamplingFromStatistic