[Biojava-dev] Distributions

Lachlan Coin lc1 at sanger.ac.uk
Thu Feb 20 09:30:50 EST 2003


If you have a CVS checkout, you will find the code in

/biojava-live/src/org/biojava/bio/dist/DistributionTools.java

so, to calculate shannon entropy for a Distribution observed to base 2,
you can put

Map entropy = DistributionTools.shannonEntropy(observedDistribution, 2)

which gives you a map of the information content of each symbol in the
alphabet (i.e. log(1/p(i))

You can also do:

double bits = DistributionTools.bitsOfInformation(observedDistribution)

to get the total information context (which is just the expectation of the
above map under the observed distribution: sum_i p(i)*log(1/p(i))


Lachlan







On Thu, 20 Feb 2003 jhidalgo at elmonte.es wrote:

> Can anyone send me an example of ShannonEntropy calculation code?
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at biojava.org
> http://biojava.org/mailman/listinfo/biojava-dev
>

-------------------------------------------------------------
Lachlan Coin
Wellcome Trust Sanger Institute		Magdalene College
Cambridge  CB10 1SA			Cambridge CB30AG
Ph: +44 1223 494 820
Fax: +44 1223 494 919
------------------------------------------------------------



More information about the biojava-dev mailing list