Skip to content

Commit

Permalink
fix MvNormal bug (#189)
Browse files Browse the repository at this point in the history
* fix MvNormal bug

* bump version
  • Loading branch information
cscherrer authored Apr 18, 2022
1 parent 7cda008 commit ab96459
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MeasureTheory"
uuid = "eadaa1a4-d27c-401d-8699-e962e1bbc33b"
authors = ["Chad Scherrer <[email protected]> and contributors"]
version = "0.15.0"
version = "0.15.1"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
15 changes: 8 additions & 7 deletions src/combinators/affine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,14 @@ end
# # lmul!(d.ω, z)
# # logdensity_def(d.parent, z)
# # end

@inline basemeasure(d::Affine{N,M,Tuple{Vararg{T,K}}}) where {K,N,M,T<:AbstractArray} = affine(getfield(d, :f), rootmeasure(d.parent))

@inline function basemeasure(d::Affine{N,M,Tuple{A}}) where {N,M,A<:AbstractArray}
weightedmeasure(-logjac(d), OrthoLebesgue(params(d)))
end

@inline function basemeasure(d::Affine{N,M,Tuple{A1,A2}}) where {N,M,A1<:AbstractArray, A2<:AbstractArray}
weightedmeasure(-logjac(d), OrthoLebesgue(params(d)))
end

@inline basemeasure(d::Affine) = affine(getfield(d, :f), basemeasure(d.parent))

Expand All @@ -238,11 +244,6 @@ end
@inline basemeasure(d::Affine{N,L}) where {N,L<:Lebesgue} = weightedmeasure(-logjac(d), d.parent)
@inline basemeasure(d::Affine{N,L}) where {N,L<:LebesgueMeasure} = weightedmeasure(-logjac(d), d.parent)


@inline function basemeasure(d::Affine{N,P, Tuple{Vararg{T, K}}}) where {K,N,L<:Union{<:Lebesgue, <:LebesgueMeasure},P<:PowerMeasure{L}, T<:AbstractArray}
weightedmeasure(-logjac(d), OrthoLebesgue(params(d)))
end

logjac(d::Affine) = logjac(getfield(d, :f))

function Random.rand!(
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ end
d = MvNormal=σ)
x = rand(d)
@test logdensityof(d, x) logdensityof(Dists.MvNormal(Σ), x)
@test logdensityof(MvNormal(zeros(3), σ), x) logdensityof(d, x)
end

@testset "NegativeBinomial" begin
Expand Down

2 comments on commit ab96459

@cscherrer
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/58683

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.15.1 -m "<description of version>" ab9645963e3fab66dede0499a1be062d178a4d9c
git push origin v0.15.1

Please sign in to comment.