Learn R Programming

experDesign (version 0.4.0)

entropy: Calculates the entropy

Description

Calculates the entropy of a category. It uses the amount of categories to scale between 0 and 1.

Usage

entropy(x)

Value

The numeric value of the Shannon entropy scaled between 0 and 1.

Arguments

x

A character or vector with two or more categories

Examples

Run this code
entropy(c("H", "T", "H", "T"))
entropy(c("H", "T", "H", "T", "H", "H", "H"))
entropy(c("H", "T", "H", "T", "H", "H", NA))
entropy(c("H", "T", "H", "T", "H", "H"))
entropy(c("H", "H", "H", "H", "H", "H", NA))

Run the code above in your browser using DataLab