Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement prefix for Distributions.jl and depreciate NamedDist. #759

Open
yebai opened this issue Dec 19, 2024 · 2 comments
Open

Implement prefix for Distributions.jl and depreciate NamedDist. #759

yebai opened this issue Dec 19, 2024 · 2 comments

Comments

@yebai
Copy link
Member

yebai commented Dec 19, 2024

Let's use prefix to replace the slightly redundant NamedDist:

"""
A named distribution that carries the name of the random variable with it.
"""
struct NamedDist{variate,support,Td<:Distribution{variate,support},Tv<:VarName} <:
Distribution{variate,support}
dist::Td
name::Tv
end

x ~ prefix(Normal(), "var_`") # store `var_x` instead of `x` in `varinfo`. 
@penelopeysm
Copy link
Member

penelopeysm commented Dec 20, 2024

Why do we even need NamedDist (or any mechanism to control the name)? Functionally, is there any difference between

var_x ~ Normal()
x = var_x

and

x ~ prefix(Normal(), "var_")

? I guess the former introduces an extra variable into the local scope, but I can't imagine why that should be a problem.

@penelopeysm
Copy link
Member

Ah, I see, it lets people programmatically generating variable names. Urk.

I think it would make far more sense if this could be implemented on the LHS of the tilde, rather than the RHS. But I see that this has been discussed before.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants