|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
de.jstacs.sequenceScores.differentiable.UniformDiffSS
de.jstacs.sequenceScores.statisticalModels.differentiable.UniformDiffSM
public class UniformDiffSM
This DifferentiableStatisticalModel
does nothing. So it is possible to save
parameters in an optimization.
Field Summary |
---|
Fields inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore |
---|
alphabets, length, r |
Fields inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore |
---|
UNKNOWN |
Constructor Summary | |
---|---|
UniformDiffSM(AlphabetContainer alphabets,
int length,
double ess)
This is the main constructor that creates an instance of a UniformDiffSM that models each sequence uniformly. |
|
UniformDiffSM(StringBuffer xml)
This is the constructor for the interface Storable . |
Method Summary | |
---|---|
void |
addGradientOfLogPriorTerm(double[] grad,
int start)
This method computes the gradient of DifferentiableStatisticalModel.getLogPriorTerm() for each
parameter of this model. |
DataSet |
emitDataSet(int numberOfSequences,
int... seqLength)
This method returns a DataSet object containing artificial
sequence(s). |
protected void |
extractFurtherInformation(StringBuffer xml)
This method is the opposite of UniformDiffSS.getFurtherInformation() . |
double |
getESS()
Returns the equivalent sample size (ess) of this model, i.e. the equivalent sample size for the class or component that is represented by this model. |
protected StringBuffer |
getFurtherInformation()
This method is used to append further information of the instance to the XML representation. |
double |
getLogNormalizationConstant()
Returns the logarithm of the sum of the scores over all sequences of the event space. |
double |
getLogPartialNormalizationConstant(int parameterIndex)
Returns the logarithm of the partial normalization constant for the parameter with index parameterIndex . |
double |
getLogPriorTerm()
This method computes a value that is proportional to
where prior is the prior for the parameters of this model. |
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 |
getLogScoreAndPartialDerivation(Sequence seq,
int start,
IntList indices,
DoubleList dList)
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 |
getLogScoreFor(Sequence seq,
int start)
Returns the logarithmic score for the Sequence seq
beginning at position start in the Sequence . |
byte |
getMaximalMarkovOrder()
This method returns the maximal used Markov order, if possible. |
int[][] |
getSamplingGroups(int parameterOffset)
Returns groups of indexes of parameters that shall be drawn together in a sampling procedure |
int |
getSizeOfEventSpaceForRandomVariablesOfParameter(int index)
Returns the size of the event space of the random variables that are affected by parameter no. |
void |
initializeFunction(int index,
boolean meila,
DataSet[] data,
double[][] weights)
This method creates the underlying structure of the DifferentiableSequenceScore . |
boolean |
isNormalized()
This method indicates whether the implemented score is already normalized to 1 or not. |
String |
toString()
|
Methods inherited from class de.jstacs.sequenceScores.differentiable.UniformDiffSS |
---|
fromXML, getCurrentParameterValues, getInstanceName, getNumberOfParameters, initializeFunctionRandomly, isInitialized, setParameters, toXML |
Methods inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore |
---|
clone, getAlphabetContainer, getCharacteristics, getInitialClassParam, getLength, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumberOfRecommendedStarts, getNumberOfStarts, getNumericalCharacteristics |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore |
---|
clone, getCurrentParameterValues, getInitialClassParam, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunctionRandomly, setParameters |
Methods inherited from interface de.jstacs.sequenceScores.SequenceScore |
---|
getAlphabetContainer, getCharacteristics, getInstanceName, getLength, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumericalCharacteristics, isInitialized |
Methods inherited from interface de.jstacs.Storable |
---|
toXML |
Constructor Detail |
---|
public UniformDiffSM(AlphabetContainer alphabets, int length, double ess)
UniformDiffSM
that models each sequence uniformly.
alphabets
- the AlphabetContainer
length
- the length of the modeled sequencesess
- the equivalent sample size (ess) of the classpublic UniformDiffSM(StringBuffer xml) throws NonParsableException
Storable
.
Creates a new UniformDiffSM
out of its XML
representation as returned by UniformDiffSS.fromXML(StringBuffer)
.
xml
- the XML representation as StringBuffer
NonParsableException
- if the XML representation could not be parsedMethod Detail |
---|
public double getLogScoreFor(Sequence seq, int start)
SequenceScore
Sequence
seq
beginning at position start
in the Sequence
.
getLogScoreFor
in interface SequenceScore
getLogScoreFor
in class UniformDiffSS
seq
- the Sequence
start
- the start position in the Sequence
Sequence
public double getLogScoreAndPartialDerivation(Sequence seq, int start, IntList indices, DoubleList dList)
DifferentiableSequenceScore
Sequence
beginning at
position start
in the Sequence
and fills lists with
the indices and the partial derivations.
getLogScoreAndPartialDerivation
in interface DifferentiableSequenceScore
getLogScoreAndPartialDerivation
in class UniformDiffSS
seq
- the Sequence
start
- the start position in the Sequence
indices
- an IntList
of indices, after method invocation the
list should contain the indices i where
dList
- a DoubleList
of partial derivations, after method
invocation the list should contain the corresponding
Sequence
protected StringBuffer getFurtherInformation()
UniformDiffSS
getFurtherInformation
in class UniformDiffSS
StringBuffer
UniformDiffSS.extractFurtherInformation(StringBuffer)
protected void extractFurtherInformation(StringBuffer xml) throws NonParsableException
UniformDiffSS
UniformDiffSS.getFurtherInformation()
. It
extracts further information of the instance from a XML representation.
extractFurtherInformation
in class UniformDiffSS
xml
- the StringBuffer
containing the information to be
extracted as XML code
NonParsableException
- if the StringBuffer
could not be parsedUniformDiffSS.getFurtherInformation()
public double getLogNormalizationConstant()
DifferentiableStatisticalModel
getLogNormalizationConstant
in interface DifferentiableStatisticalModel
public void initializeFunction(int index, boolean meila, DataSet[] data, double[][] weights)
DifferentiableSequenceScore
DifferentiableSequenceScore
.
initializeFunction
in interface DifferentiableSequenceScore
initializeFunction
in class UniformDiffSS
index
- the index of the class the DifferentiableSequenceScore
modelsmeila
- indicates whether the (reduced) parameterization is useddata
- the samplesweights
- the weights of the sequences in the samplespublic int getSizeOfEventSpaceForRandomVariablesOfParameter(int index)
DifferentiableStatisticalModel
index
, i.e. the product of the
sizes of the alphabets at the position of each random variable affected
by parameter index
. For DNA alphabets this corresponds to 4
for a PWM, 16 for a WAM except position 0, ...
getSizeOfEventSpaceForRandomVariablesOfParameter
in interface DifferentiableStatisticalModel
index
- the index of the parameter
public double getLogPartialNormalizationConstant(int parameterIndex) throws Exception
DifferentiableStatisticalModel
parameterIndex
. This is the logarithm of the partial derivation of the
normalization constant for the parameter with index
parameterIndex
,
getLogPartialNormalizationConstant
in interface DifferentiableStatisticalModel
parameterIndex
- the index of the parameter
Exception
- if something went wrong with the normalizationDifferentiableStatisticalModel.getLogNormalizationConstant()
public double getESS()
DifferentiableStatisticalModel
getESS
in interface DifferentiableStatisticalModel
public String toString()
toString
in class UniformDiffSS
public double getLogPriorTerm()
DifferentiableStatisticalModel
DifferentiableStatisticalModel.getESS()
* DifferentiableStatisticalModel.getLogNormalizationConstant()
+ Math.log( prior )
prior
is the prior for the parameters of this model.
getLogPriorTerm
in interface DifferentiableStatisticalModel
getLogPriorTerm
in interface StatisticalModel
DifferentiableStatisticalModel.getESS()
* DifferentiableStatisticalModel.getLogNormalizationConstant()
+ Math.log( prior ).
DifferentiableStatisticalModel.getESS()
,
DifferentiableStatisticalModel.getLogNormalizationConstant()
public void addGradientOfLogPriorTerm(double[] grad, int start)
DifferentiableStatisticalModel
DifferentiableStatisticalModel.getLogPriorTerm()
for each
parameter of this model. The results are added to the array
grad
beginning at index start
.
addGradientOfLogPriorTerm
in interface DifferentiableStatisticalModel
grad
- the array of gradientsstart
- the start index in the grad
array, where the
partial derivations for the parameters of this models shall be
enteredDifferentiableStatisticalModel.getLogPriorTerm()
public boolean isNormalized()
DifferentiableStatisticalModel
false
.
isNormalized
in interface DifferentiableStatisticalModel
true
if the implemented score is already normalized
to 1, false
otherwisepublic int[][] getSamplingGroups(int parameterOffset)
SamplingDifferentiableStatisticalModel
getSamplingGroups
in interface SamplingDifferentiableStatisticalModel
parameterOffset
- a global offset on the parameter indexes
parameterOffset
.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 sequence
Exception
- if the sequence could not be handled by the model
NotTrainedException
- if the model is not trained yetStatisticalModel.getLogProbFor(Sequence, int, int)
public double getLogProbFor(Sequence sequence) throws Exception
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
returned
Exception
- if the sequence could not be handled by the model
NotTrainedException
- if the model is not trained yetStatisticalModel.getLogProbFor(Sequence, int, int)
public double getLogProbFor(Sequence sequence, int startpos, int endpos) throws Exception
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 account
Exception
- if the sequence could not be handled (e.g.
startpos >
, endpos
> sequence.length
, ...) by the model
NotTrainedException
- if the model is not trained yetpublic 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 sample 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 sampleseqLength
- 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 yet
Exception
- 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |