JS_divergence: Distance measures for topics

JS_divergenceR Documentation

Distance measures for topics

Description

Distance measures in convenient forms for the purposes of this package. JS_divergence gives the Jensen-Shannon divergence (see below) between two vectors (understood as distributions over the index) or between two matrices (row-wise), and cosine_distance gives the cosine distance between two matrices (row-wise).

Usage

JS_divergence(x, y)

cosine_distance(x, y)

Arguments

x, y

matrices of the same dimensions, or vectors (JS_divergence only).

Details

The Jensen-Shannon divergence between P and Q is given by

(1/2) ∑ P(j) log (2P(j) / (P(j) + Q(j))) + Q(j) log (2Q(j) / (P(j) + Q(j)))

setting x log x = 0 by definition.

Value

For matrices, the result has the distance between x[i, ] and y[j, ] in the i, j position.

See Also

topic_divergences, row_dists, model_distances


agoldst/dfrtopics documentation built on July 15, 2022, 4:13 p.m.