Comments (4)
Can we define a generalization of the bijectors used for lower bounded, upper bounded and both? Would a coupling flow be useful here?
Yeah, so that's one approach that came up at some point where we basically define a TrunactedBijector
which just reimplements the link
and invlink
for these distributions. You could do something like
# Could also implement this for the case of `Bijector{1}`
struct TruncatedBijector{T} <: Bijector{0}
lb::T
ub::T
end
function (b::TruncatedBijector)(x::Real)
a, b = b.lb, b.ub
lowerbounded, upperbounded = isfinite(a), isfinite(b)
if lowerbounded && upperbounded
return StatsFuns.logit((x - a) / (b - a))
elseif lowerbounded
return log(x - a)
elseif upperbounded
return log(b - x)
else
return x
end
end
function (ib::Inversed{<:TruncatedBijector})(y::Real)
a, b = ib.orig.lb, ib.orig.ub
lowerbounded, upperbounded = isfinite(a), isfinite(b)
if lowerbounded && upperbounded
return (b - a) * StatsFuns.logistic(y) + a
elseif lowerbounded
return exp(y) + a
elseif upperbounded
return b - exp(y)
else
return y
end
end
function logabsdetjac(b::TruncatedBijector, x::Real)
a, b = b.lb, b.ub
lowerbounded, upperbounded = isfinite(a), isfinite(b)
if lowerbounded && upperbounded
return - log((x - a) * (b - x) / (b - a))
elseif lowerbounded
return - log(x - a)
elseif upperbounded
return - log(b - x)
else
return zero(x)
end
end
from bijectors.jl.
I just want to point out that this has been solved for all cases except Truncated
for which runtime information is required to be able to determine which transformation is necessary. This was done in PR #39.
from bijectors.jl.
Can we define a generalization of the bijectors used for lower bounded, upper bounded and both? Would a coupling flow be useful here?
from bijectors.jl.
Closed by #52
from bijectors.jl.
Related Issues (20)
- TransformVariables-like example? HOT 6
- Support InverseFunctions.jl and ChangesOfVariables.jl HOT 65
- MethodError: no method matching `(::Inverse)...`
- Zygote error differentiating `Coupling` HOT 4
- `PlanarLayer` broken in 0.9.9 HOT 17
- OrderedBijector gives surprising results HOT 13
- Road to DensityInterface? HOT 11
- Rewrite: what do we want
- Fitting normalizing flow HOT 2
- Matrix Variate Bijectors - Lower/Uppertriangular transforms
- Zygote AD & `logpdf` for transformed multivariate
- `Bijectors.ordered(d)` is incorrect if `bijector(d)` is not `Identity` HOT 1
- Adding support for FunctionChains.jl? HOT 9
- Problem compiling an app with Turing
- MethodError: no method matching bijector(::MixtureModel{Multivariate, Continuous, MvNormal, Float64}) HOT 1
- CorrBijector makes posterior improper HOT 7
- SimplexBijector tests fails on boundary
- Remove heavy usage of `@generated`
- Questions on custom bijectors HOT 1
- Bijector for MatrixNormal HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bijectors.jl.