Open jaksle opened 3 months ago
I think something like this would be sufficient:
_quad(d::AbstractMvNormal, t::AbstractVector) = dot(t, cov(d), t)
_quad(d::MvNormal, t::AbstractVector) = PDMats.quad(cov(d), t)
_quad(d::MvNormalCanon, t::AbstractVector) = PDMats.invquad(d.J, t)
function cf(d::AbstractMvNormal, t::AbstractVector)
return exp(im * dot(mean(d), t) - _quad(d, t) / 2)
end
function mgf(d::AbstractMvNormal, t::AbstractVector)
return exp(dot(mean(d), t) + _quad(d, t) / 2)
end
Thanks! This looks simple and good.
This is pretty confusing. The characteristic function of multivariate normal distribution
cf(d::MvNormal, t::AbstractVector)
is the simplest thing there is for it, and it seems it is not implemented! (The same formgf
.)I could try adding it myself, but I see the current implementation of
MvNormal
is careful in handling generalAbstractMatrix
/AbstractVector
as covariance matrix and mean vector, so that calculations are always efficient and I am not sure how to replicate that.