Skip to contents

This function computes \(D_{KL}(p||q)\), where \(p\sim \text{U}(a,b)\) and \(q\sim \mathcal{N}(\mu,\sigma^2)\).

Usage

kld_uniform_gaussian(a = 0, b = 1, mu = 0, sigma2 = 1)

Arguments

a, b

Parameters of uniform (true) distribution

mu, sigma2

Parameters of Gaussian (approximate) distribution

Value

A scalar (the Kullback-Leibler divergence)

Examples

kld_uniform_gaussian(a = 0, b = 1, mu = 0, sigma2 = 1)
#> [1] 1.085605