The methods in this package keep track of absolute log Jacobian determinants by returning an extra value. This is somewhat brittle, I am proposing an alternative way of doing it.
Let
import Distributions: logpdf
struct LogJacVariate{T,S}
x::T
logjac::S
end
logpdf(d, v::LogJacVariate) = logpdf(d, v.x) + v.logjac
Then the API that replaces transform_and_logjac would just return a LogJacVariate.
Caveats: Distributions.jl is a heavy dependency. Factoring out the core, as proposed eg in JuliaStats/Distributions.jl#1139, would make this much easier.
The methods in this package keep track of absolute log Jacobian determinants by returning an extra value. This is somewhat brittle, I am proposing an alternative way of doing it.
Let
Then the API that replaces
transform_and_logjacwould just return aLogJacVariate.Caveats: Distributions.jl is a heavy dependency. Factoring out the core, as proposed eg in JuliaStats/Distributions.jl#1139, would make this much easier.