public final class DistributionTools extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
areEmissionSpectraEqual(Distribution[] a,
Distribution[] b)
Compares the emission spectra of two distribution arrays.
|
static boolean |
areEmissionSpectraEqual(Distribution a,
Distribution b)
Compares the emission spectra of two distributions.
|
static Distribution |
average(Distribution[] dists)
Averages two or more distributions.
|
static double |
bitsOfInformation(Distribution observed)
Calculates the total bits of information for a distribution.
|
static Distribution |
countToDistribution(Count c)
Make a distribution from a count.
|
static Distribution[] |
distOverAlignment(Alignment a)
Equivalent to distOverAlignment(a, false, 0.0).
|
static Distribution[] |
distOverAlignment(Alignment a,
boolean countGaps)
Creates an array of distributions, one for each column of the alignment.
|
static Distribution[] |
distOverAlignment(Alignment a,
boolean countGaps,
double nullWeight)
Creates an array of distributions, one for each column of the alignment.
|
protected static Sequence |
generateOrderNSequence(String name,
OrderNDistribution d,
int length)
Deprecated.
use generateSequence() or generateSymbolList() instead.
|
static Sequence |
generateSequence(String name,
Distribution d,
int length)
Produces a sequence by randomly sampling the Distribution.
|
static SymbolList |
generateSymbolList(Distribution d,
int length)
Produces a
SymbolList by randomly sampling a Distribution. |
static Distribution |
jointDistOverAlignment(Alignment a,
boolean countGaps,
double nullWeight,
int[] cols)
Creates a joint distribution.
|
static HashMap |
KLDistance(Distribution observed,
Distribution expected,
double logBase)
A method to calculate the Kullback-Liebler Distance (relative entropy).
|
static void |
randomizeDistribution(Distribution d)
Randomizes the weights of a
Distribution . |
static Distribution |
readFromXML(InputStream is)
Read a distribution from XML.
|
static HashMap |
shannonEntropy(Distribution observed,
double logBase)
A method to calculate the Shannon Entropy for a Distribution.
|
static double |
totalEntropy(Distribution observed)
Calculates the total Entropy for a Distribution.
|
static void |
writeToXML(Distribution d,
OutputStream os)
Writes a Distribution to XML that can be read with the readFromXML method.
|
public static void writeToXML(Distribution d, OutputStream os) throws IOException
d
- the Distribution to write.os
- where to write it to.IOException
- if writing failspublic static Distribution readFromXML(InputStream is) throws IOException, SAXException
is
- an InputStream to read fromIOException
- if is failedSAXException
- if is could not be processed as XMLpublic static void randomizeDistribution(Distribution d) throws ChangeVetoException
Distribution
.d
- the Distribution
to randomizeChangeVetoException
- if the Distribution is lockedpublic static Distribution countToDistribution(Count c)
c
- the countFiniteAlphabet
as c
and trained with the counts of c
public static final boolean areEmissionSpectraEqual(Distribution a, Distribution b) throws BioException
a
- A Distribution
with the same Alphabet
as
b
b
- A Distribution
with the same Alphabet
as
a
BioException
- if one or both of the Distributions are over infinite alphabets.public static final boolean areEmissionSpectraEqual(Distribution[] a, Distribution[] b) throws BioException
a
- A Distribution[]
consisting of Distributions
over a FiniteAlphabet
b
- A Distribution[]
consisting of Distributions
over a FiniteAlphabet
BioException
- if one of the Distributions is over an infinite
alphabet.public static final HashMap KLDistance(Distribution observed, Distribution expected, double logBase)
logBase
- - the log base for the entropy calculation. 2 is standard.observed
- - the observed frequence of Symbols
.expected
- - the excpected or background frequency.(Double)
relative entropy.public static final HashMap shannonEntropy(Distribution observed, double logBase)
logBase
- - the log base for the entropy calculation. 2 is standard.observed
- - the observed frequence of Symbols
.(Double)
entropy.public static double totalEntropy(Distribution observed)
Symbols
are weighted by their probability of occurence.observed
- the observed frequence of Symbols
.Distribution
.public static final double bitsOfInformation(Distribution observed)
observed
- - the observed frequence of Symbols
.Distribution
.public static Distribution[] distOverAlignment(Alignment a) throws IllegalAlphabetException
a
- the AlignmentIllegalAlphabetException
- if the alignment alphabet is not
compattiblepublic static final Distribution jointDistOverAlignment(Alignment a, boolean countGaps, double nullWeight, int[] cols) throws IllegalAlphabetException
a
- the Alignment
to build the Distribution[]
over.countGaps
- if true gaps will be included in the distributions
(NOT YET IMPLEMENTED!!, CURRENTLY EITHER OPTION WILL PRODUCE THE SAME RESULT)nullWeight
- the number of pseudo counts to add to each distributioncols
- a list of positions in the alignment to include in the joint distributionDistribution
IllegalAlphabetException
- if all sequences don't use the same alphabetpublic static final Distribution[] distOverAlignment(Alignment a, boolean countGaps, double nullWeight) throws IllegalAlphabetException
a
- the Alignment
to build the Distribution[]
over.countGaps
- if true gaps will be included in the distributionsnullWeight
- the number of pseudo counts to add to each distribution,
pseudo counts will not affect gaps, no gaps, no gap counts.Distribution[]
where each member of the array is a
Distribution
of the Symbols
found at that position
of the Alignment
.IllegalAlphabetException
- if all sequences don't use the same alphabetpublic static final Distribution[] distOverAlignment(Alignment a, boolean countGaps) throws IllegalAlphabetException
countGaps
- if true gaps will be included in the distributionsa
- the Alignment
to build the Distribution[]
over.Distribution[]
where each member of the array is a
Distribution
of the Symbols
found at that position
of the Alignment
.IllegalAlphabetException
- if the alignment is not composed from sequences all
with the same alphabetpublic static final Distribution average(Distribution[] dists)
dists
- the Distributions
to averageDistribution
were the weight of each Symbol
is the average of the weights of that Symbol
in each Distribution
.public static final Sequence generateSequence(String name, Distribution d, int length)
name
- the name for the sequenced
- the distribution to sample. If this distribution is of order N a
seed sequence is generated allowed to 'burn in' for 1000 iterations and used
to produce a sequence over the conditioned alphabet.length
- the number of symbols in the sequence.public static final SymbolList generateSymbolList(Distribution d, int length)
SymbolList
by randomly sampling a Distribution.d
- the distribution to sample. If this distribution is of order N a
seed sequence is generated allowed to 'burn in' for 1000 iterations and used
to produce a sequence over the conditioned alphabet.length
- the number of symbols in the sequence.length
protected static final Sequence generateOrderNSequence(String name, OrderNDistribution d, int length)
name
- the name of the sequenced
- the distribution to samplelength
- the length of the sequenceCopyright © 2014 BioJava. All rights reserved.