Skip to contents

Calculates Hellinger distance for each pair of rows in the given matrix, or each combination of rows from the two matrices

Usage

# S3 method for class 'Matrix'
hellinger(mx1, mx2 = NULL, ...)

Arguments

mx1

First matrix, \(n_1 \times k\)

mx2

Optional second matrix, \(n_2 \times k\)

Value

Matrix of size \(n_1 \times n_1\) or \(n_1 \times n_2\)

Examples

set.seed(2022-06-09)
mx1 = rdirichlet(3, rep(5, 5))
mx2 = rdirichlet(3, rep(5, 5))
hellinger(mx1)
#>           [,1]      [,2]         [,3]
#> [1,] 0.0000000 0.3067419 2.668745e-01
#> [2,] 0.3067419 0.0000000 1.230902e-01
#> [3,] 0.2668745 0.1230902 1.053671e-08
hellinger(mx1, mx2)
#>           [,1]      [,2]       [,3]
#> [1,] 0.2361547 0.2632094 0.33018266
#> [2,] 0.1777705 0.1060308 0.12270871
#> [3,] 0.1296687 0.1732766 0.08788004