<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->

# Function kldivergence

Calculate the Kullback-Leibler (KL) divergence  between two distributions


## Syntax

```js
math.kldivergence(x, y)
```

### Parameters

Parameter | Type | Description
--------- | ---- | -----------
`q` | Array &#124; Matrix | First vector
`p` | Array &#124; Matrix | Second vector

### Returns

Type | Description
---- | -----------
number | Returns distance between q and p


### Throws

Type | Description
---- | -----------


## Examples

```js
math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])   //returns 0.24376698773121153

```


