abstract type PSDTrait end
struct IsPSDParametrization <: PSDTrait end
struct IsNotPSDParametrization <: PSDTrait end
For any custom MyPSDType to be considered a parametrization of a PSD matrix, it needs to implement
ispsdparametrization(::MyPSDType) = IsNotPSDParametrization()
psdparametrization(::Type{T}, P::MyPSDType) = psdparametrization(T, P) # converts the eltype of P into T
and some additional things from Base such as eltype.
Constructing Normal distributions and kernels
Normal distributions can now be constructed by Normal(m, P)
Normal kernels with constant conditional covariance can now be constructed by NormalKernel(m, P) (m needs to be callable for things to work of course).
Sampling from Normal distributions
For sampling of multivariate Normals to work lsqrt(P::MyPSDType) currently needs to return a square left-root.
For sampling of univariate Normals to work MyPSDType needs to subtype Real (This can be fixed).
Marginalization
For marginalization to work the following needs to be implemented:
stein(P::MyPSDType, A::AbstractMatrix) # A * P * A'
stein(P::MyPSDType, A::AbstractMatrix, Q::SomeOtherPSDType) # A * P * A' +Q
Conditioning
For conditioning to work the following needs to be implemented:
schur_reduce(Π::MyPSDType, C::AbstractMatrix) # returns marginal measurement cov, kalman gain, conditional cov
schur_reduce(Π::MyPSDType, C::AbstractMatrix, R::SomeOtherPSDType) # same as above but with measurement noise
Additional details
Numeric type restrictions in method signatures have been removed. This means some things that should work do and some exotic things that should work does not. In particular, if you get the correct result when mixing Complex and Real numeric types, then you are very lucky.
With the above in mind should the numeric type parameter be dropped from AbstractDistributions? So that a type parameter can be dropped from Normal, e.g. struct Norma{TM,TC} <: AbstractDistribution; m::TM; P::TC end
Convenience constructors for affine conditional means have been removed, e.g. you have to do NormalKernel(AffineMap(A, b), Q) rather than NormalKernel(A, b, Q). Reason is that this lead to some method ambiguities as NormalKernel now has a type parameter for PSDTrait to distinguish the case of constant and non-constant conditional covariances.
Fixes #106
PSDParametrizations
New types:
For any custom
MyPSDType
to be considered a parametrization of a PSD matrix, it needs to implementand some additional things from
Base
such aseltype
.Constructing Normal distributions and kernels
Normal(m, P)
NormalKernel(m, P)
(m needs to be callable for things to work of course).Sampling from Normal distributions
lsqrt(P::MyPSDType)
currently needs to return a square left-root.MyPSDType
needs to subtypeReal
(This can be fixed).Marginalization
For marginalization to work the following needs to be implemented:
Conditioning
For conditioning to work the following needs to be implemented:
Additional details
Complex
andReal
numeric types, then you are very lucky.AbstractDistributions
? So that a type parameter can be dropped fromNormal
, e.g.struct Norma{TM,TC} <: AbstractDistribution; m::TM; P::TC end
NormalKernel(AffineMap(A, b), Q)
rather thanNormalKernel(A, b, Q)
. Reason is that this lead to some method ambiguities asNormalKernel
now has a type parameter forPSDTrait
to distinguish the case of constant and non-constant conditional covariances.TODO