From 92085f1f458dd17c2f5a179d5b2013d7ad8d122a Mon Sep 17 00:00:00 2001 From: cgarling Date: Tue, 2 Apr 2024 06:24:11 -0400 Subject: [PATCH 1/2] Fix univariate `loglikelihood` doc --- docs/src/univariate.md | 2 +- src/univariates.jl | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/src/univariate.md b/docs/src/univariate.md index 0b2c48c6e..914cab2f0 100644 --- a/docs/src/univariate.md +++ b/docs/src/univariate.md @@ -73,7 +73,7 @@ pdfsquaredL2norm insupport(::UnivariateDistribution, x::Any) pdf(::UnivariateDistribution, ::Real) logpdf(::UnivariateDistribution, ::Real) -loglikelihood(::UnivariateDistribution, ::AbstractArray) +loglikelihood(::UnivariateDistribution, ::Real) cdf(::UnivariateDistribution, ::Real) logcdf(::UnivariateDistribution, ::Real) logdiffcdf(::UnivariateDistribution, ::Real, ::Real) diff --git a/src/univariates.jl b/src/univariates.jl index b60e5a294..5778a8467 100644 --- a/src/univariates.jl +++ b/src/univariates.jl @@ -326,7 +326,13 @@ logpdf(d::UnivariateDistribution, x::Real) # extract value from array of zero dimension logpdf(d::UnivariateDistribution, x::AbstractArray{<:Real,0}) = logpdf(d, first(x)) -# loglikelihood for `Real` +""" + loglikelihood(d::UnivariateDistribution, x::Real) + +Evaluate the logarithm of the likelihood at `x`. + +See also: [`logpdf`](@ref). +""" Base.@propagate_inbounds loglikelihood(d::UnivariateDistribution, x::Real) = logpdf(d, x) """ From 1b5a62e2615bc5b0853a9bdfd85bb5521c654c7c Mon Sep 17 00:00:00 2001 From: cgarling Date: Tue, 2 Apr 2024 06:42:13 -0400 Subject: [PATCH 2/2] Fix multivariate `pdf` and `logpdf` docs --- docs/src/multivariate.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/multivariate.md b/docs/src/multivariate.md index c4e7c1764..a4a077ef0 100644 --- a/docs/src/multivariate.md +++ b/docs/src/multivariate.md @@ -31,8 +31,8 @@ entropy(::MultivariateDistribution, ::Real) ```@docs insupport(::MultivariateDistribution, ::AbstractArray) -pdf(::MultivariateDistribution, ::AbstractArray) -logpdf(::MultivariateDistribution, ::AbstractArray) +pdf(::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,M}) where {N,M} +logpdf(::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,M}) where {N,M} loglikelihood(::MultivariateDistribution, ::AbstractVector{<:Real}) ``` **Note:** For multivariate distributions, the pdf value is usually very small or large, and therefore direct evaluation of the pdf may cause numerical problems. It is generally advisable to perform probability computation in log scale.