# CalcHellingerDist: Calculate Hellinger Distance In textmineR: Functions for Text Mining and Topic Modeling

## Description

Calculates the Hellinger distances or the rows or columns of a numeric matrix or for two numeric vectors.

## Usage

 `1` ```CalcHellingerDist(x, y = NULL, by_rows = TRUE) ```

## Arguments

 `x` A numeric matrix or numeric vector `y` A numeric vector. `y` must be specified if `x` is a numeric vector. `by_rows` Logical. If `x` is a matrix, should distances be calculated by rows?

## Value

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`.

## Examples

 ```1 2 3 4 5 6``` ```x <- rchisq(n = 100, df = 8) y <- x^2 CalcHellingerDist(x = x, y = y) mymat <- rbind(x, y) CalcHellingerDist(x = mymat) ```

### Example output

```Loading required package: Matrix
[1] 0.1463276
x         y
x 0.0000000 0.1463276
y 0.1463276 0.0000000
```

textmineR documentation built on June 28, 2021, 9:08 a.m.