cross_entropy: Cross Entropy

Description Usage Arguments Value Examples

View source: R/crossentropy.R

Description

Compute the cross entropy between the "true" and "unnatural" distributions p and q from associated time series ps and qs, respectively. Cross entropy’s local variant is equivalent to the self-information of q, and as such is implemented by the local block entropy.

Usage

1
cross_entropy(ps, qs)

Arguments

ps

Vector specifying a time series drawn from the true distribution.

qs

Vector specifying a time series drawn from the unnatural distribution.

Value

Numeric giving the cross entropy.

Examples

1
2
3
4
ps <- c(0, 1, 1, 0, 1, 0, 0, 1, 0, 0)
qs <- c(0, 0, 0, 0, 0, 1, 1, 0, 0, 1)
cross_entropy(ps, qs)      # 1.003530
cross_entropy(qs, ps)      # 0.912454

rinform documentation built on April 1, 2018, 12:12 p.m.