R/entropy.R

Defines functions entropy

## Compute the entropy of a distribution

entropy <- function(distrib, base=exp(1))
	{
		distrib <- distrib[distrib!=0]
		p <- distrib/sum(distrib)
		e <- -sum(p*log(p, base=base))
		return(e)
	}

Try the TraMineR package in your browser

Any scripts or data that you put into this service are public.

TraMineR documentation built on April 12, 2025, 1:53 a.m.