simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

kldivergence.md (688B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function kldivergence
      4 
      5 Calculate the Kullback-Leibler (KL) divergence  between two distributions
      6 
      7 
      8 ## Syntax
      9 
     10 ```js
     11 math.kldivergence(x, y)
     12 ```
     13 
     14 ### Parameters
     15 
     16 Parameter | Type | Description
     17 --------- | ---- | -----------
     18 `q` | Array &#124; Matrix | First vector
     19 `p` | Array &#124; Matrix | Second vector
     20 
     21 ### Returns
     22 
     23 Type | Description
     24 ---- | -----------
     25 number | Returns distance between q and p
     26 
     27 
     28 ### Throws
     29 
     30 Type | Description
     31 ---- | -----------
     32 
     33 
     34 ## Examples
     35 
     36 ```js
     37 math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])   //returns 0.24376698773121153
     38 
     39 ```
     40 
     41