DiffableDistributions.jl
Render the distributions in Distributions.jl compatible with automatic differentiation in ForwardDiff.jl
The strategy:
- This requires that each distribution
d
derives fromAbstract<d>
. - We create a parameterized, differentiable distribution corresponding to each
d
. Thus, for the case ofNormal <: AbstractNormal
, we have:
immutable DNormal{T <: Real} <: AbstractNormal
μ::T
σ::T
end
- We then extend
Normal
with an outer constructor that, when any argumentx::ForwardDiff.ForwardDiffNumber
, delegates to a constructor forDNormal
. - This allows
Normal
to continue as a leaf type while allowing differentiability to be facilitated transparently through parameterized distributions.