% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/clustering-methods.R
\name{entropy}
\alias{entropy}
\alias{np}
\alias{modal_category}
\title{Calculate the entropy of a vector}
\usage{
entropy(v, pseudo_count = length(v)/1000, na.action = na.fail)

np(v, p = 0.05, pseudo_count = p/5, na.action = na.fail)

modal_category(v, na.action = na.fail)
}
\arguments{
\item{v}{categorical vector}

\item{pseudo_count}{number of pseudo counts to add on, to stabilize empty categories}

\item{na.action}{how to handle NA values}

\item{p}{proportion threshold}
}
\value{
the sample entropy
}
\description{
Calculate the entropy of a vector
}
\section{Functions}{
\itemize{
\item \code{np}: The number of categories exceeding \code{p} proportion of the total

\item \code{modal_category}: The modal category of v.  Ties are broken by lexicographic order of the factor levels.
}}

\examples{
v2 = gl(2, 4)
v4 = gl(4, 4)
stopifnot(entropy(v2) < entropy(v4))
v_empty = v2[1:4] #empty level 2
stopifnot(is.finite(entropy(v_empty))) # pseudo_count

np(v4, p = .2, pseudo_count = 0)
np(v4, p = .25, pseudo_count = 0)
np(v4, p = .25, pseudo_count = .0001)

modal_category(v4)
modal_category(v4[-1])

}
