mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
638 B
638 B
Function kldivergence
Calculate the Kullback-Leibler (KL) divergence between two distributions
Syntax
math.kldivergence(x, y)
Parameters
| Parameter | Type | Description |
|---|---|---|
q |
Array | Matrix | First vector |
p |
Array | Matrix | Second vector |
Returns
| Type | Description |
|---|---|
| number | Returns distance between q and p |
Examples
math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5]); //returns 0.24376698773121153