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

Cannot input BlockDiagonal into MvNormal in Distributions.jl #102

Closed
biona001 opened this issue Jun 20, 2022 · 0 comments · Fixed by #106
Closed

Cannot input BlockDiagonal into MvNormal in Distributions.jl #102

biona001 opened this issue Jun 20, 2022 · 0 comments · Fixed by #106

Comments

@biona001
Copy link

biona001 commented Jun 20, 2022

I'm not sure if this is a bug with Distributions.jl or BlockDiagonals.jl...

I have a block diagonal matrix V where each block is explicitly wrapped by Symmetric, but I cannot input V into the MvNormal constructor in Distributions.jl.

x1 = rand(5, 5)
x2 = rand(5, 5)
V1 = Symmetric(x1'*x1)
V2 = Symmetric(x2'*x2)
V = BlockDiagonal([V1, V2])
μ = rand(10)
MvNormal(μ, V)


MethodError: Cannot `convert` an object of type 
  BlockDiagonal{Float64{},Symmetric{Float64, Matrix{Float64}}} to an object of type 
  BlockDiagonal{Float64{},UpperTriangular{Float64, Matrix{Float64}}}
Closest candidates are:
  convert(::Type{T}, ::Factorization) where T<:AbstractArray at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/factorization.jl:58
  convert(::Type{T}, ::T) where T<:AbstractArray at abstractarray.jl:14
  convert(::Type{T}, ::T) where T at essentials.jl:205

Stacktrace:
 [1] PDMats.PDMat(mat::BlockDiagonal{Float64, Symmetric{Float64, Matrix{Float64}}}, chol::Cholesky{Float64, BlockDiagonal{Float64, UpperTriangular{Float64, Matrix{Float64}}}})
   @ PDMats ~/.julia/packages/PDMats/YXkIE/src/pdmat.jl:16
 [2] PDMats.PDMat(mat::BlockDiagonal{Float64, Symmetric{Float64, Matrix{Float64}}})
   @ PDMats ~/.julia/packages/PDMats/YXkIE/src/pdmat.jl:19
 [3] MvNormal::Vector{Float64}, Σ::BlockDiagonal{Float64, Symmetric{Float64, Matrix{Float64}}})
   @ Distributions ~/.julia/packages/Distributions/N1Ika/src/multivariate/mvnormal.jl:201
 [4] top-level scope
   @ In[144]:6
 [5] eval
   @ ./boot.jl:360 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1116

I have no idea why it's trying to convert a symmetric matrix into an uppertriangular matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant