Skip to content

Commit c2a7387

Browse files
authored
More efficient sampling with MvNormalCanon (#1977)
1 parent 406fe02 commit c2a7387

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
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"

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)