-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comparison to TransformVariables and Bijectors? #23
Comments
I confess that I had forgotten that AFAICT the primary conceptual differences are that ParameterHandling.jl is interested in completely arbitrary data structures, whereas TransformVariables.jl is interested specifically in the bijections utilised when working with random variables, and ParameterHandling breaks down into two steps what TransformVariables does in one. TransformVariablesIIUC, TransformVariables.jl exposes (in addition to a number of transforms, and operations on those transforms) one function for constructing transformations which map from vectors of reals to other data structures, whose values respect certain constraints: # My understanding based on these docs: https://tamaspapp.eu/TransformVariables.jl/stable/#The-as-constructor-and-aggregations
t = as(T, data...) # "constructor"
t = as(data....) # used for "aggregations"
as(Real, 0.0, ∞) maps the real line to the positive reals, and t = as((μ = asℝ, σ = asℝ₊, τ = asℝ₊, θs = as(Array, 8))) maps from 11-dimensional Euclidean space to a My suspicion is that ParameterHandlingParameterHandling.jl exposes a two-function API, rather than one: x_flat, unflatten = flatten(x)
ParameterHandling.value(x)
Separately, ParameterHandling.jl defines a collection of things which subtype x = positive(5.0)
x isa ParameterHandling.Positive
ParameterHandling.value(x) == 5.0
One could implement the example from TransformVariables in ParameterHandling as follows: # TransformVariables version.
t = as((μ = asℝ, σ = asℝ₊, τ = asℝ₊, θs = as(Array, 8)))
# ParameterHandling vesion.
x_flat, unflatten = flatten((
μ=5.0,
σ=positive(2.0),
τ=positive(1.1),
θs=randn(8),
))
# The same transformation in either framework.
x_tv = t(x_flat)
x_ph = ParameterHandling.value(unflatten(x_flat))
all(map(isapprox, x_tv, x_ph)) # return true Notable DifferencesThese APIs are really quite similar, but there are a few differences. The TransformVariables interface allows one to specify the transform without providing an initial value, whereas ParameterHandling builds the transform from the initial value. For the simple examples above, this distinction isn't particularly important. It's possible that the ParameterHandling interface is a little more convenient in that it provides the initial value in the transformed space, whereas I think you'd have to separately write The ParameterHandling approach has the minor advantage that things like I think the differences start to really show when you consider doing something more compicated like x = deferred(Normal, 5.0, positive(1.0))
x_flat, unflatten = flatten(x)
ParameterHandling.value(x) The Presumably TransformVariables could handle stuff like this with some modification / extension, but I'm not completely sure how you would make sense of things like Conversely, ParameterHandling doesn't have anything to say about The reason that we went down the route of requiring that you provide us with an actual piece of data to apply @cscherrer does this make sense? |
Thanks @willtebbutt , this is really helpful. It seem like this approach could make it more flexible about types, so you could put easily use
For calls like Given the similarities to TransformVariables, do you think there is a nice way to have them under a common interface?
This is great. We're working through some similar issues in MeasureTheory, and I've started working more and more in terms of Thanks for the detailed description! |
Exactly. Indeed, some
Well in the particular case of
Probably. You could certainly implement TransformVariables in terms of ParameterHandling -- maybe the converse is true also? I wonder whether @tpapp has any thoughts? |
Hi, from the README this looks very similar to TransformVariables, and to some special cases of Bijectors. How is this package different from those? It would be helpful to have some details on this in the README, to help users know which of the three packages is the best fit for their use case.
The text was updated successfully, but these errors were encountered: