Skip to content

Commit 585a805

Browse files
authored
Merge branch 'JuliaStats:master' into doctests
2 parents 4ef1373 + c2a7387 commit 585a805

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Distributions"
22
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
33
authors = ["JuliaStats"]
4-
version = "0.25.119"
4+
version = "0.25.120"
55

66
[deps]
77
AliasTables = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
@@ -44,7 +44,7 @@ ForwardDiff = "0.10, 1"
4444
JSON = "0.21"
4545
LinearAlgebra = "<0.0.1, 1"
4646
OffsetArrays = "1"
47-
PDMats = "0.10, 0.11"
47+
PDMats = "0.11.35"
4848
Printf = "<0.0.1, 1"
4949
QuadGK = "2"
5050
Random = "<0.0.1, 1"

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

src/multivariate/mvnormalcanon.jl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,13 @@ sqmahal!(r::AbstractVector, d::MvNormalCanon, x::AbstractMatrix) = quad!(r, d.J,
170170

171171
# Sampling (for GenericMvNormal)
172172

173-
unwhiten_winv!(J::AbstractPDMat, x::AbstractVecOrMat) = unwhiten!(inv(J), x)
174-
unwhiten_winv!(J::PDiagMat, x::AbstractVecOrMat) = whiten!(J, x)
175-
unwhiten_winv!(J::ScalMat, x::AbstractVecOrMat) = whiten!(J, x)
176-
if isdefined(PDMats, :PDSparseMat)
177-
unwhiten_winv!(J::PDSparseMat, x::AbstractVecOrMat) = x[:] = J.chol.PtL' \ x
178-
end
179-
180173
function _rand!(rng::AbstractRNG, d::MvNormalCanon, x::AbstractVector)
181-
unwhiten_winv!(d.J, randn!(rng, x))
174+
invunwhiten!(d.J, randn!(rng, x))
182175
x .+= d.μ
183176
return x
184177
end
185178
function _rand!(rng::AbstractRNG, d::MvNormalCanon, x::AbstractMatrix)
186-
unwhiten_winv!(d.J, randn!(rng, x))
179+
invunwhiten!(d.J, randn!(rng, x))
187180
x .+= d.μ
188181
return x
189182
end

0 commit comments

Comments
 (0)