Description Usage Arguments Value Examples
View source: R/distance_functions.R
This function calculates the Jensen Shannon Divergence for the rows or columns of a numeric matrix or for two numeric vectors.
1 | CalcJSDivergence(x, y = NULL, by_rows = TRUE)
|
x |
A numeric matrix or numeric vector |
y |
A numeric vector. |
by_rows |
Logical. If |
If x
is a matrix, this returns an square and symmetric matrix.
The i,j entries correspond to the Hellinger Distance between the rows of x
(or the columns of x
if by_rows = FALSE
). If x
and y
are vectors, this returns a numeric scalar whose value is the Hellinger Distance
between x
and y
.
1 2 3 4 5 6 | x <- rchisq(n = 100, df = 8)
y <- x^2
CalcJSDivergence(x = x, y = y)
mymat <- rbind(x, y)
CalcJSDivergence(x = mymat)
|
Loading required package: Matrix
[1] 0.02806598
x y
x 0.00000000 0.02806598
y 0.02806598 0.00000000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.