entropy {CellaRepertorium} | R Documentation

## Calculate the entropy of a vector

### Description

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

`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

- `np`: The number of categories exceeding `p` proportion of the total

- `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])

[Package CellaRepertorium version 1.2.0 Index]