Learn R Programming

cummeRbund (version 2.14.0)

shannon.entropy: Shannon entropy

Description

Calculates the Shannon entropy for a probability distribution

Usage

shannon.entropy(p)

Arguments

p
A vector of probabilities (must sum to ~1)

Value

Returns a numeric value for the Shannon entropy of the supplied probability distribution

Details

None

References

None

Examples

Run this code
	x<-sample(1:500,50)
	p<-x/sum(x)
	shannon.entropy(p)

Run the code above in your browser using DataLab