Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft MvNormal #122

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0920b69
draft MvNormal
cscherrer Jul 28, 2021
0541c76
make sizes static
cscherrer Jul 29, 2021
e2ac0ea
bugfixes
cscherrer Jul 29, 2021
d6889eb
zero allocations!
cscherrer Jul 29, 2021
3f5e714
version from @chriselrod with column-major traversal
cscherrer Jul 29, 2021
6fb62ed
CorrCholesky update
cscherrer Jul 29, 2021
78c59b7
add InlineTest and ReTest
cscherrer Jul 29, 2021
3fce183
mucking about
cscherrer Aug 3, 2021
aa8af50
updates
cscherrer Aug 3, 2021
25337c5
more MvNormal work
cscherrer Aug 4, 2021
4c10ea5
moar turbo
cscherrer Aug 4, 2021
dd47907
combine loops
cscherrer Aug 4, 2021
b1cc218
Merge remote-tracking branch 'origin/master' into cs-mvnormal
cscherrer Aug 5, 2021
f0fa99a
drop InlineTest
cscherrer Aug 5, 2021
fedacd1
Merge branch 'cs-mvnormal' of github.com:cscherrer/MeasureTheory.jl i…
cscherrer Aug 5, 2021
1459cc6
add Static
cscherrer Aug 5, 2021
26659c3
version bound for Static.jl
cscherrer Aug 5, 2021
33c9452
reorg
cscherrer Aug 6, 2021
bc30b33
update
cscherrer Aug 6, 2021
ea11d25
Move code to MultivariateMeasures.jl
cscherrer Aug 6, 2021
a86716e
drop `using LoopVectorization`
cscherrer Aug 6, 2021
e62d419
delete benchmarks (moved to MultivariateMeasures)
cscherrer Aug 6, 2021
3893d54
drop old array code (moved to MultivariateMeasures)
cscherrer Aug 6, 2021
e974c42
Move multivariate transforms to MultivariateMeasures
cscherrer Aug 6, 2021
7344016
moved CorrCholesky test
cscherrer Aug 6, 2021
fa5b18e
move LKJCholesky to MultivariateMeasures
cscherrer Aug 6, 2021
5a82db4
drop refernce to lkj-cholesky.jl (moved to MultivariateMeasures
cscherrer Aug 8, 2021
882ad05
drop corrcholesky reference
cscherrer Aug 8, 2021
09d9604
drop ordered reference
cscherrer Aug 8, 2021
f36b8c5
drop PositiveFactorizations dependency (not used)
cscherrer Aug 9, 2021
6e1fca0
drop old LKJCholesky test
cscherrer Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
NamedTupleTools = "d9ec5142-1e00-5aa0-9d6a-321866360f50"
NestedTuples = "a734d2a7-8d68-409b-9419-626914d4061d"
PositiveFactorizations = "85a6dd25-e78a-55b7-8502-1745935b8125"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
Expand All @@ -39,7 +38,6 @@ MacroTools = "0.5"
MappedArrays = "0.3, 0.4"
NamedTupleTools = "0.13"
NestedTuples = "0.3"
PositiveFactorizations = "0.2"
SpecialFunctions = "0.10, 1"
StatsFuns = "0.9"
TransformVariables = "0.4"
Expand Down
6 changes: 3 additions & 3 deletions src/MeasureTheory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ include("parameterized/bernoulli.jl")
include("parameterized/poisson.jl")
include("parameterized/binomial.jl")
include("parameterized/multinomial.jl")
include("parameterized/lkj-cholesky.jl")
# include("parameterized/lkj-cholesky.jl")
include("parameterized/negativebinomial.jl")

include("transforms/corrcholesky.jl")
include("transforms/ordered.jl")
# include("transforms/corrcholesky.jl")
# include("transforms/ordered.jl")

include("density.jl")
# include("pushforward.jl")
Expand Down
109 changes: 0 additions & 109 deletions src/parameterized/lkj-cholesky.jl

This file was deleted.

53 changes: 8 additions & 45 deletions src/parameterized/mvnormal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,18 @@ using Random
import Base


struct MvNormal{N, T, I, J} <: ParameterizedMeasure{N}
par::NamedTuple{N, T}
end
@parameterized MvNormal(μ, Σ)

@kwstruct MvNormal(Σ)

function MvNormal(nt::NamedTuple{N,T}) where {N,T}
I,J = mvnormaldims(nt)
@kwstruct MvNormal(μ, Σ)

cache = Vector{Float64}(undef, max(I,J))
MvNormal{N,T,I,J}(cache, nt)
end
@kwstruct MvNormal(σ)

function Base.size(d::MvNormal{N, T, I, J}) where {N,T,I,J}
return (I,)
end
@kwstruct MvNormal(μ, σ)

mvnormaldims(nt::NamedTuple{(:A, :b)}) = size(nt.A)
@kwstruct MvNormal(μ, Ω)

function MeasureTheory.basemeasure(μ::MvNormal{N, T, I,I}) where {N, T, I}
return (1 / sqrt2π)^I * Lebesgue(ℝ)^I
end
@kwstruct MvNormal(Ω)

sampletype(d::MvNormal{N, T, I, J}) where {N,T,I,J} = Vector{Float64}

MvNormal(; kwargs...) = begin
MvNormal((; kwargs...))
end



function Random.rand!(rng::AbstractRNG, d::MvNormal{(:A, :b),T,I,J}, x::AbstractArray) where {T,I,J}
z = getcache(d, J)
rand!(rng, Normal()^J, z)
copyto!(x, d.b)
mul!(x, d.A, z, 1.0, 1.0)
return x
end

function logdensity(d::MvNormal{(:A,:b)}, x)
cache = getcache(d, size(d))
z = d.A \ (x - d.b)
return logdensity(MvNormal(), z) - logabsdet(d.A)
end

≪(::MvNormal, ::Lebesgue{ℝ}) = true

# function logdensity(d::MvNormal{(:Σ⁻¹,)}, x)
# @tullio ℓ = -0.5 * x[i] * d.Σ⁻¹[i,j] * x[j]
# return ℓ
# end

mvnormaldims(nt::NamedTuple{(:Σ⁻¹,)}) = size(nt.Σ⁻¹)
@kwstruct MvNormal(ω)
46 changes: 0 additions & 46 deletions src/transforms/corrcholesky.jl

This file was deleted.

40 changes: 0 additions & 40 deletions src/transforms/corrcholeskylower.jl

This file was deleted.

Loading