entropy: Calculate entropy of categorical data

Description Usage Arguments Details Value

View source: R/entropy.R

Description

Calculate entropy of categorical data using tally of observations in each category.

Usage

1
entropy(x, freq = table(x))

Arguments

x

ordered; vector of categorical data.

freq

numeric; count of observations in each group.

Details

Calculates the entropy of categorical data using a tally of observations in each category, using the following formula:

H=- ∑ [f_{k} log2 (f_{k} / ∑ f_{j})] / sum f_{j},

where f_{k} is the frequency in category indexed by k.

Value

numeric; scalar value of entropy.


stephematician/miForang documentation built on July 23, 2019, 5:11 p.m.