Skip to content
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

Issues with the dot-tilde (i.e. .~) syntax #761

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

Issues with the dot-tilde (i.e. .~) syntax #761

yebai opened this issue Dec 19, 2024 · 5 comments

Comments

@yebai
Copy link
Member

yebai commented Dec 19, 2024

Below is copied from #710 (comment)

I lean towards removing the dot syntax. The benefits of using dot syntax against a loop or fillarray/product_distribution are relatively marginal compared to its complexity and lack of robustness.

@yebai
Copy link
Member Author

yebai commented Dec 19, 2024

@willtebbutt
Copy link
Member

I would also be in favour of removing the .~ syntax -- could you remind me what the benefits of it are? I vaguely remember there being a couple of things that it can be used to do, that someone mentioned being trickier with fillarray / product_distribution.

@mhauru
Copy link
Member

mhauru commented Jan 6, 2025

Might poll our userbase on Slack, see if anyone is desperate to keep .~. I would be very glad if we could get rid of it, but don't want to break user code lightly.

@torfjelde
Copy link
Member

I would also be in favour of removing the .~ syntax -- could you remind me what the benefits of it are? I vaguely remember there being a couple of things that it can be used to do, that someone mentioned being trickier with fillarray / product_distribution.

There are "semantic" differences.

x ~ filldist(Normal(), 2)

treats x as a multivariate random variable of length 2, while

x .~ Normal()

treats x as a vector of 2 univariate random variables. This is effectively the difference between a multivariate random variable vs. a vector of IID variables.

@yebai
Copy link
Member Author

yebai commented Jan 6, 2025

Here is the idea I mentioned briefly during the meeting. We lower

x .~ Normal()

to

x = tilde_assume!!(__context__, IIDDistribution(Normal()), __varinfo__)

Then, we overload tilde_assume!! for IIDDistribution to store each RV x[i] separately in __varinfo__. This allows users to individually apply model operations like condition/fix on x[i].

We could make this work for other distribution sugars by overloading the tilde_assume!! (also tilde_observe!!) interfaces for new types like IIDDistribution.

EDIT: I am happy to remove the .~ feature if we can't find a good, robust workaround.

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

No branches or pull requests

4 participants