Skip to content

Commit

Permalink
Merge pull request JuliaLang#427 from mschauer/kl
Browse files Browse the repository at this point in the history
Use Wikipedia's language in the docstring to kldivergence.
  • Loading branch information
mschauer authored Nov 14, 2018
2 parents 66b0a16 + 37dfde6 commit aa64239
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scalarstats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,10 @@ crossentropy(p::AbstractArray{T}, q::AbstractArray{T}, b::Real) where {T<:Real}
"""
kldivergence(p, q, [b])
Compute the Kullback-Leibler divergence of `q` from `p`, optionally specifying
a real number `b` such that the divergence is scaled by `1/log(b)`.
Compute the Kullback-Leibler divergence from `q` to `p`,
also called the relative entropy of `p` with respect to `q`,
that is the sum `pᵢ * log(pᵢ / qᵢ)`. Optionally a real number `b`
can be specified such that the divergence is scaled by `1/log(b)`.
"""
function kldivergence(p::AbstractArray{T}, q::AbstractArray{T}) where T<:Real
length(p) == length(q) || throw(DimensionMismatch("Inconsistent array length."))
Expand Down

0 comments on commit aa64239

Please sign in to comment.