-
Notifications
You must be signed in to change notification settings - Fork 6
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
[FR] Real Param
is <:Real
#51
Comments
Can't you just extract the values from the wrappers before using? E.g. We can't make |
Adding to what @rafaqz said: μ = Param(0.8, bounds=(0.2, 0.9))
σ = Param(0.8, bounds=(1.2, 1.9))
s_μ = Uniform(μ.bounds...)
s_σ = Uniform(σ.bounds...)
# Alternatively...
# TriangularDist(a, b, c)
s_μ = TriangularDist(μ.bounds..., (μ.val + μ.bounds[1]) / (μ.bounds[2] - σ.bounds[1]))
s_σ = TriangularDist(σ.bounds..., (σ.val + σ.bounds[1]) / (σ.bounds[2] - σ.bounds[1]))
d = Normal(rand(s_μ), rand(s_σ)) You could wrap all this up into your own |
I just hit this myself. You're right, its a real pain using Distributions.jl with We should be able to just stick a One problem with The |
I don't understand... what is the use case where you can't just strip the param types first? |
Building the model structure with the distribution embedded in it. Say you want a field of you model to be some user defined distribution containing some parameters you need to optimise. Currently you would need to define a field to hold the distribution type and a field to hold a tuple of Or treat the fields as function and run them at some point after the optimiser rebuilds the object with new parameters: transitions = let
kw = (; bounds=(0, 10.0))
e1 = Param(1.0; kw...)
e2 = Param(1.0; kw...)
e3 = Param(1.0; kw...)
(;
a=() -> Exponential(e1),
b=() -> Exponential(e2),
c=() -> Exponential(e3),
)
end In this case its the anonymous function struct that we can rebuild! But it needs the function call step, and its arcane and noone will be able to understand how it works. Compared to: kw = (; bounds=(0, 10.0))
transitions = (;
a=Exponential(Param(1.0; kw...)),
b=Exponential(Param(1.0; kw...)),
c=Exponential(Param(1.0; kw...)),
) (This is a sub-component of a much larger model) |
Maybe we can add a kw = (; bounds=(0, 10.0))
transitions = (;
a=Deferred(Exponential, Param(1.0; kw...)),
b=Deferred(Exponential, Param(1.0; kw...)),
c=Defered(Exponential, Param(1.0; kw...)),
) Then we can construct the distribution when we do Basically every option here sucks. Probably defining |
We now have |
Impressive package!
Tracking parameters is a problem in complex models. Your solution is elegant and does not require manual tracking.
Fantastic!
I would like to use it for statistics models.
Do you think it is possible for the real
Param
be<:Real
? It would allow combining withDistributions.jl
MWE
The text was updated successfully, but these errors were encountered: