Skip to content

Commit 406fe02

Browse files
tpappdevmotion
andauthored
Document and export gradlogpdf. (#1974)
* Document and export gradlogpdf. Fixes #1844. * Update src/Distributions.jl Co-authored-by: David Widmann <devmotion@users.noreply.github.com> --------- Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
1 parent efff906 commit 406fe02

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/src/univariate.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pdfsquaredL2norm
7272
insupport(::UnivariateDistribution, x::Any)
7373
pdf(::UnivariateDistribution, ::Real)
7474
logpdf(::UnivariateDistribution, ::Real)
75+
gradlogpdf(::Distribution, ::Any)
7576
loglikelihood(::UnivariateDistribution, ::AbstractArray)
7677
cdf(::UnivariateDistribution, ::Real)
7778
logcdf(::UnivariateDistribution, ::Real)

src/common.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ be disabled by using `@inbounds`.
256256
Instead of `logpdf` one should implement `_logpdf(d, x)` which does not have to check the
257257
size of `x`.
258258
259-
See also: [`pdf`](@ref).
259+
See also: [`pdf`](@ref), [`gradlogpdf`](@ref).
260260
"""
261261
@inline function logpdf(
262262
d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,M}
@@ -280,6 +280,17 @@ See also: [`pdf`](@ref).
280280
end
281281
end
282282

283+
"""
284+
gradlogpdf(d::Distribution, x)
285+
286+
Evaluate the gradient of the logarithm of the probability density function of `d` at `x`.
287+
288+
For univariate distributions, return the derivative.
289+
290+
See also: [`logpdf`](@ref).
291+
"""
292+
function gradlogpdf end
293+
283294
# `_logpdf` should be implemented and has no default definition
284295
# _logpdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}
285296

0 commit comments

Comments
 (0)