Learn R Programming

dad (version 4.1.6)

ddjeffreys: Divergence between probability distributions of discrete variables given samples

Description

jeffreys's divergence (symmetrized Kullback-Leibler divergence) between two multivariate (\(q > 1\)) or univariate (\(q = 1\)) discrete probability distributions, estimated from samples.

Usage

ddjeffreys(x1, x2)

Value

The divergence between the two probability distributions.

Arguments

x1, x2

vectors or data frames of \(q\) columns (can also be a tibble).

If they are data frames and have not the same column names, there is a warning.

Author

Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Sabine Demotes-Mainard

Details

Let \(p_1\) and \(p_2\) denote the estimated probability distributions of the discrete samples \(x_1\) and \(x_2\). The jeffreys's divergence between the discrete probability distributions of the samples are computed using the ddjeffreyspar function.

References

Deza, M.M. and Deza E. (2013). Encyclopedia of distances. Springer.

See Also

ddjeffreyspar: Jeffrey's distances between two discrete distributions, given the probabilities on their common support.

Other distances: ddchisqsym, ddhellinger, ddjensen, ddlp.

Examples

Run this code
# Example 1
x1 <- c("A", "A", "B", "B")
x2 <- c("A", "A", "A", "B", "B")
ddjeffreys(x1, x2)

# Example 2 (Its value can be infinity -Inf-)
x1 <- c("A", "A", "B", "C")
x2 <- c("A", "A", "A", "B", "B")
ddjeffreys(x1, x2)

# Example 3
x1 <- data.frame(x = factor(c("A", "A", "A", "B", "B", "B")),
                 y = factor(c("a", "a", "a", "b", "b", "b")))                 
x2 <- data.frame(x = factor(c("A", "A", "A", "B", "B")),
                 y = factor(c("a", "a", "b", "a", "b")))
ddjeffreys(x1, x2)

Run the code above in your browser using DataLab