I’m a Julia noob and I’m trying to get BayesianDataFusion.jl to work with 0.6. I found that the issue I have is related to the deprecation of immutable
to using struct
. I created an attempt at a fix but I have zero confidence in it. I also opened an issue on the package’s github page but I don’t think the maintainer will get to it soon issue 9. You can see below the original code and my fix. Does anyone have suggestions on a better attempt?
Deprecated 0.5 code
using Compat
using Distributions
using PDMats
import Base.LinAlg: Cholesky
immutable NormalWishart <: Distribution
dim::Int
zeromean::Bool
mu::Vector{Float64}
kappa::Float64
#Tchol::Cholesky{Float64} # Precision matrix (well, sqrt of one)
T::Matrix{Float64}
nu::Float64
function NormalWishart(mu::Vector{Float64}, kappa::Real,
T::Matrix{Float64}, nu::Real)
# Probably should put some error checking in here
d = length(mu)
zmean::Bool = true
for i = 1:d
if mu[i] != 0.
zmean = false
break
end
end
@compat new(d, zmean, mu, Float64(kappa), full(Symmetric(T)), Float64(nu))
end
end
function NormalWishart(mu::Vector{Float64}, kappa::Real,
T::AbstractMatrix{Float64}, nu::Real)
NormalWishart(mu, kappa, full(T), nu)
end
import Distributions.rand
function rand(nw::NormalWishart)
Lam = rand(Wishart(nw.nu, nw.T))
mu = rand(MvNormal(nw.mu, full(inv(Symmetric(Lam))) ./ nw.kappa))
return (mu, Lam)
end
Attempted fix for 0.6
struct NormalWishart{I<:Int, B<:Bool, Num<:Real, ST<:AbstractPDMat} <: ContinuousMatrixDistribution
dim::I
zeromean::B
mu::Vector{Num}
kappa::Num
#Tchol::Cholesky{Num} # Precision matrix (well, sqrt of one)
T::ST
nu::Num
end