View source: R/ddjeffreyspar.R

ddjeffreyspar | R Documentation |

Jeffreys divergence (symmetrized Kullback-Leibler divergence) between two discrete probability distributions on the same support (which can be a Cartesian product of `q`

sets) , given the probabilities of the states (which are `q`

-tuples) of the support.

```
ddjeffreyspar(p1, p2)
```

`p1` |
array (or table) the dimension of which is |

`p2` |
array (or table) the dimension of which is |

Jeffreys divergence `||p_1 - p_2||`

between two discrete distributions `p_1`

and `p_2`

is given by the formula:

`||p_1 - p_2|| = \sum_x{(p_1(x) - p_2(x)) log(p_1(x)/p_2(x))}`

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

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

`ddjeffreys`

: Jeffreys distance between two estimated discrete distributions, given samples.

Other distances: `ddchisqsympar`

, `ddhellingerpar`

, `ddjensenpar`

, `ddlppar`

.

```
# Example 1
p1 <- array(c(1/2, 1/2), dimnames = list(c("a", "b")))
p2 <- array(c(1/4, 3/4), dimnames = list(c("a", "b")))
ddjeffreyspar(p1, p2)
# Example 2
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")))
p1 <- table(x1)/nrow(x1)
p2 <- table(x2)/nrow(x2)
ddjeffreyspar(p1, p2)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.