shannonEntr {MethylIT.utils}R Documentation

Compute Shannon Entropy

Description

Compute Shannon Entropy of probability vector p.

Usage

shannonEntr(p, logbase = 2)

Arguments

p

A probability vector, sum(p) = 1.

logbase

A positive number: the base with respect to which logarithms

Details

By definition, if p_i = 0 for some i, the value of the corresponding summ and 0*log(0) is taken to be 0.

Examples

counts = sample.int(10)
prob = counts/sum(counts)
shannonEntr(prob)

[Package MethylIT.utils version 0.3.1 ]