Skip to content

Questions on custom bijectors #234

@vboussange

Description

@vboussange

Hey guys, I really like that you provide this package independently from Turing.jl. I am actually making intensive use of Bijectors.jl for a project that I have called PiecewiseInference.jl.

I need to define few custom bijectors, and I would like to make sure that I am doing things right. Here is one that transforms a random variable with values in $\mathbb{R}$ to a random variable with values in $[C, \infty)$. Here is my code for it.

struct AbsCap{N,C} <: Bijector{N} 
    c::C
end
(a::AbsCap)(x) = x .- a.c # transform itself, "forward"
(a::Inverse{<: AbsCap})(y) = abs.(y) .+ a.orig.c # inverse transform, "backward"
logabsdetjac(::Abs{0}, y::Real) = zero(eltype(y))

Is everything alright in this piece of code?

Thanks a lot for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions