entropy: Calculate the entropy of a vector

Description Usage Arguments Value Functions Examples

Description

Calculate the entropy of a vector

Usage

1
2
3
4
5
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

v

categorical vector

pseudo_count

number of pseudo counts to add on, to stabilize empty categories

na.action

how to handle NA values

p

proportion threshold

Value

the sample entropy

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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])

CellaRepertorium documentation built on Nov. 8, 2020, 7:48 p.m.