shannon.entropy: Calculate the Shannon entropy

Description Usage Arguments Details Value Author(s) Examples

View source: R/util-methods.r

Description

This function calculates the Shannon entropy for a discrete random variable with finite n values sample.

Usage

1

Arguments

p

A numeric object with non-negative values.

Details

The entropy is calculated by H(x) = -sum_i^n(P(x_i)log_b(P(x_i))).

Value

A numeric value of entropy is returned.

Author(s)

Ge Tan

Examples

1
2
3
4
  x <- c(1, 1, 1, 1)
  shannon.entropy(x)
  x <- c(1, 0, 0, 0)
  shannon.entropy(x)

ge11232002/TFBSTools documentation built on Sept. 12, 2021, 12:07 p.m.