|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.models.utils.ModelTester
public class ModelTester
This class is useful for some test for any (discrete) models. It implements several statistics (loglikelihood, Shannon entropy, AIC, BIC, ...) to compare models.
AbstractModel
Nested Class Summary | |
---|---|
static class |
ModelTester.SeqIterator
|
Constructor Summary | |
---|---|
ModelTester()
|
Method Summary | |
---|---|
static double |
getKLDivergence(Model m1,
Model m2,
int length)
Returns the Kullback-Leibler-divergence D(p_m1||p_m2). |
static double |
getLogLikelihood(Model m,
Sample data)
Returns the loglikelihood of a sample data for a given
model m . |
static double |
getLogLikelihood(Model m,
Sample data,
double[] weights)
Returns the loglikelihood of a sample data for a given
model m . |
static double |
getMarginalDistribution(Model m,
int[] constraint)
This method computes the marginal distribution for any discrete model m and all sequences that fulfil the
constraint , if possible. |
static double |
getMaxOfDeviation(Model m1,
Model m2,
int length)
This method computes the maximum deviation between the probabilties for the all sequences of length for discrete models
m1 and m2 . |
static Sequence |
getMostProbableSequence(Model m,
int length)
Returns one most probable sequence for the discrete model m . |
static double |
getShannonEntropy(Model m,
int length)
This method computes the Shannon Entropy for any discrete model m and all sequences of length , if
possible. |
static double |
getShannonEntropyInBits(Model m,
int length)
This method computes the Shannon Entropy in bits for any discrete model m and all sequences of length , if
possible. |
static double |
getSumOfDeviation(Model m1,
Model m2,
int length)
This method computes the sum of deviations between the probabilties for the all sequences of length for discrete models
m1 and m2 . |
static double |
getSumOfDistribution(Model m,
int length)
This method computes the marginal distribution for any discrete model m and all sequences of length , if
possible. |
static double |
getSymKLDivergence(Model m1,
Model m2,
int length)
Returns the difference of the Kullback-Leibler-divergences, i.e. |
static double |
getValueOfAIC(Model m,
Sample s,
int k)
This method computes the value of Akaikes Information Criterion (AIC). |
static double |
getValueOfBIC(Model m,
Sample s,
int k)
This method computes the value of Bayesian Information Criterion (BIC). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ModelTester()
Method Detail |
---|
public static double getKLDivergence(Model m1, Model m2, int length) throws Exception
\sum_x p(x|m1) * \log \frac{p(x|m1)}{p(x|m2)}.
m1
- one discrete modelm2
- another discrete modellength
- the length of the sequence (for inhomogeneous models length
has to be getLength())
Exception
public static double getSymKLDivergence(Model m1, Model m2, int length) throws Exception
\sum_x (p(x|m1)-p(x|m2)) * \log \frac{p(x|m1)}{p(x|m2)}.
m1
- one discrete modelm2
- another discrete modellength
- the length of the sequence (for inhomogeneous models length
has to be getLength())
Exception
public static double getLogLikelihood(Model m, Sample data) throws Exception
data
for a given
model m
.
m
- given modeldata
- the sample
Exception
- if something went wrongpublic static double getLogLikelihood(Model m, Sample data, double[] weights) throws Exception
data
for a given
model m
.
m
- given modeldata
- the sampleweights
- the weights for each element of the sample
Exception
- if something went wrongpublic static double getMarginalDistribution(Model m, int[] constraint) throws Exception
m
and all sequences that fulfil the
constraint
, if possible.
m
- a discrete modelconstraint
- constraint[i] < 0
stands for a irrelavant
position, constraint[i] = c
with
0 <= c < m.getAlphabets()[(m.getLength==0)?0:i].getAlphabetLength()
is the encoded character of position i
Exception
public static double getMaxOfDeviation(Model m1, Model m2, int length) throws Exception
length
for discrete models
m1
and m2
.
Exception
public static Sequence getMostProbableSequence(Model m, int length) throws Exception
m
.
(Maybe there are more than one most probable sequences. In this case only
one is returned.)
m
- the discrete modellength
- the length of the sequence (for inhomogeneous models length
has to be getLength())
Exception
public static double getShannonEntropy(Model m, int length) throws Exception
m
and all sequences of length
, if
possible.
Exception
public static double getShannonEntropyInBits(Model m, int length) throws Exception
m
and all sequences of length
, if
possible.
Exception
public static double getSumOfDeviation(Model m1, Model m2, int length) throws Exception
length
for discrete models
m1
and m2
.
Exception
public static double getSumOfDistribution(Model m, int length) throws Exception
m
and all sequences of length
, if
possible. So this method can be used to give a hind whether a model is a
distribution or if some mistakes are in the implementation.
Math.abs( 1.0d - getSumOfDistribution( m, length )
should
be smaller than 1E-10
.
Exception
public static double getValueOfAIC(Model m, Sample s, int k) throws Exception
log
L(t,x) - 2*k, where L(t,x)
is the likelihood of the sample and k is the number of parameters in the
model.
m
- a trained models
- the sample for the testk
- the number of parameters in the model m
Exception
public static double getValueOfBIC(Model m, Sample s, int k) throws Exception
log
L(t,x) - k *
log
n, where L(t,x) is the likelihood of the sample, k is
the number of parameters in the model and n is the number of sequences in
the Sample.
m
- a trained models
- the sample for the testk
- the number of parameters in the model m
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |