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 Jan. 9, 2024, 3:02 p.m.