public abstract class AbstractDifferentiableStatisticalModel extends AbstractDifferentiableSequenceScore implements DifferentiableStatisticalModel
ScoreClassifier
. It implements
many methods of the interface DifferentiableStatisticalModel
.alphabets, length, r
UNKNOWN
Constructor and Description |
---|
AbstractDifferentiableStatisticalModel(AlphabetContainer alphabets,
int length)
The main constructor.
|
AbstractDifferentiableStatisticalModel(StringBuffer xml)
This is the constructor for
Storable . |
Modifier and Type | Method and Description |
---|---|
AbstractDifferentiableStatisticalModel |
clone()
Creates a clone (deep copy) of the current
DifferentiableSequenceScore
instance. |
DataSet |
emitDataSet(int numberOfSequences,
int... seqLength)
This method returns a
DataSet object containing artificial
sequence(s). |
double |
getInitialClassParam(double classProb)
Returns the initial class parameter for the class this
DifferentiableSequenceScore is responsible for, based on the class
probability classProb . |
double |
getLogProbFor(Sequence sequence)
Returns the logarithm of the probability of the given sequence given the
model.
|
double |
getLogProbFor(Sequence sequence,
int startpos)
Returns the logarithm of the probability of (a part of) the given
sequence given the model.
|
double |
getLogProbFor(Sequence sequence,
int startpos,
int endpos)
Returns the logarithm of the probability of (a part of) the given
sequence given the model.
|
double[] |
getLogScoreFor(DataSet data)
This method computes the logarithm of the scores of all sequences
in the given data set.
|
void |
getLogScoreFor(DataSet data,
double[] res)
This method computes and stores the logarithm of the scores for
any sequence in the data set in the given
double -array. |
byte |
getMaximalMarkovOrder()
This method returns the maximal used Markov order, if possible.
|
boolean |
isNormalized()
This method indicates whether the implemented score is already normalized
to 1 or not.
|
static boolean |
isNormalized(DifferentiableSequenceScore... function)
This method checks whether all given
DifferentiableStatisticalModel s
are normalized. |
fromXML, getAlphabetContainer, getCharacteristics, getLength, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreFor, getLogScoreFor, getNumberOfRecommendedStarts, getNumberOfStarts, getNumericalCharacteristics, toString
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addGradientOfLogPriorTerm, getESS, getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogPriorTerm, getSizeOfEventSpaceForRandomVariablesOfParameter
getCurrentParameterValues, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, setParameters
getAlphabetContainer, getCharacteristics, getInstanceName, getLength, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumericalCharacteristics, isInitialized, toString
public AbstractDifferentiableStatisticalModel(AlphabetContainer alphabets, int length) throws IllegalArgumentException
alphabets
- the AlphabetContainer
of this DifferentiableSequenceScore
length
- the length of this DifferentiableSequenceScore
, i.e. the length of
the modeled sequencesIllegalArgumentException
- if the length is negative or does not match with AlphabetContainer.getPossibleLength()
public AbstractDifferentiableStatisticalModel(StringBuffer xml) throws NonParsableException
Storable
. Creates a new
AbstractDifferentiableStatisticalModel
out of a StringBuffer
.xml
- the XML representation as StringBuffer
NonParsableException
- if the XML representation could not be parsedpublic AbstractDifferentiableStatisticalModel clone() throws CloneNotSupportedException
DifferentiableSequenceScore
DifferentiableSequenceScore
instance.clone
in interface DifferentiableSequenceScore
clone
in interface SequenceScore
clone
in class AbstractDifferentiableSequenceScore
DifferentiableSequenceScore
CloneNotSupportedException
- if something went wrong while cloning the
DifferentiableSequenceScore
public boolean isNormalized()
DifferentiableStatisticalModel
false
.isNormalized
in interface DifferentiableStatisticalModel
true
if the implemented score is already normalized
to 1, false
otherwisepublic static boolean isNormalized(DifferentiableSequenceScore... function)
DifferentiableStatisticalModel
s
are normalized.function
- the DifferentiableStatisticalModel
s to be checkedtrue
if all DifferentiableStatisticalModel
s are
already normalized, otherwise false
DifferentiableStatisticalModel.isNormalized()
public double getInitialClassParam(double classProb)
DifferentiableSequenceScore
DifferentiableSequenceScore
is responsible for, based on the class
probability classProb
.getInitialClassParam
in interface DifferentiableSequenceScore
getInitialClassParam
in class AbstractDifferentiableSequenceScore
classProb
- the class probabilitypublic double getLogProbFor(Sequence sequence)
StatisticalModel
length
and the alphabets
define the type of
data that can be modeled and therefore both has to be checked.getLogProbFor
in interface StatisticalModel
sequence
- the given sequence for which the logarithm of the
probability/the value of the density function should be
returnedStatisticalModel.getLogProbFor(Sequence, int, int)
public double getLogProbFor(Sequence sequence, int startpos) throws Exception
StatisticalModel
startpos
. E.g. the fixed length is 12. The length
of the given sequence is 30 and the startpos
=15 the logarithm
of the probability of the part from position 15 to 26 (inclusive) given
the model should be returned.
length
and the alphabets
define the type of
data that can be modeled and therefore both has to be checked.getLogProbFor
in interface StatisticalModel
sequence
- the given sequencestartpos
- the start position within the given sequenceException
- if the sequence could not be handled by the modelNotTrainedException
- if the model is not trained yetStatisticalModel.getLogProbFor(Sequence, int, int)
public double getLogProbFor(Sequence sequence, int startpos, int endpos)
StatisticalModel
StatisticalModel.getLogProbFor(Sequence, int)
by the fact, that the model could be
e.g. homogeneous and therefore the length of the sequences, whose
probability should be returned, is not fixed. Additionally, the end
position of the part of the given sequence is given and the probability
of the part from position startpos
to endpos
(inclusive) should be returned.
length
and the alphabets
define the type of
data that can be modeled and therefore both has to be checked.getLogProbFor
in interface StatisticalModel
sequence
- the given sequencestartpos
- the start position within the given sequenceendpos
- the last position to be taken into accountpublic double[] getLogScoreFor(DataSet data) throws Exception
SequenceScore
SequenceScore.getLogScoreFor(Sequence)
.getLogScoreFor
in interface SequenceScore
getLogScoreFor
in class AbstractDifferentiableSequenceScore
data
- the data set of sequencesException
- if something went wrongSequenceScore.getLogScoreFor(Sequence)
public void getLogScoreFor(DataSet data, double[] res) throws Exception
SequenceScore
double
-array.
SequenceScore.getLogScoreFor(Sequence)
.getLogScoreFor
in interface SequenceScore
getLogScoreFor
in class AbstractDifferentiableSequenceScore
data
- the data set of sequencesres
- the array for the results, has to have length
data.getNumberOfElements()
(which returns the
number of sequences in the data set)Exception
- if something went wrongSequenceScore.getLogScoreFor(Sequence)
,
SequenceScore.getLogScoreFor(DataSet)
public DataSet emitDataSet(int numberOfSequences, int... seqLength) throws NotTrainedException, Exception
StatisticalModel
DataSet
object containing artificial
sequence(s).
emitDataSet( int n, int l )
should return a data set with
n
sequences of length l
.
emitDataSet( int n, int[] l )
should return a data set with
n
sequences which have a sequence length corresponding to
the entry in the given array l
.
emitDataSet( int n )
and
emitDataSet( int n, null )
should return a data set with
n
sequences of length of the model (
SequenceScore.getLength()
).
Exception
.emitDataSet
in interface StatisticalModel
numberOfSequences
- the number of sequences that should be contained in the
returned data setseqLength
- the length of the sequences for a homogeneous model; for an
inhomogeneous model this parameter should be null
or an array of size 0.DataSet
containing the artificial sequence(s)NotTrainedException
- if the model is not trained yetException
- if the emission did not succeedDataSet
public byte getMaximalMarkovOrder() throws UnsupportedOperationException
StatisticalModel
getMaximalMarkovOrder
in interface StatisticalModel
UnsupportedOperationException
- if the model can't give a proper answer