TuringLang / docs

Documentation and tutorials for the Turing language
https://turinglang.org/docs/
MIT License
231 stars 99 forks source link

Use `filldist` in coinflip example #304

Closed devmotion closed 2 years ago

devmotion commented 2 years ago

When updating some other tutorials, I noticed that maybe we should use (and hence somewhat promote) filldist already in the coinflip example.

I think it should be more well-known and used (even though I would still like to unify and extend it in Distributions), since it

devmotion commented 2 years ago

e.g. using arraydist and filldist

We could deprecate filldist right away and instead use arraydist(Fill(dist, N)) but it's a bit more (too?) verbose. Internally, actually Distributions.product_distribution(Fill(dist, N)) will result in exactly the same objects and behaviour as filldist(dist, N) for almost all distributions: https://github.com/TuringLang/DistributionsAD.jl/blob/48c43f8e8062ba95542330735593b5275117e592/src/filldist.jl#L9-L12

yebai commented 2 years ago

Personally, I'd depreciate filldist and encourage users to use arraydist(Fill(dist, N)) from now. If it is too verbose, we can perhaps consider sugar syntax like arraydist(dist, IID, N) where IID indicate the relationship between elements in the array?

devmotion commented 2 years ago

IMO arraydist(Fill(...)) would be a bit simpler and more consistent API. And also closer to something like product or product_distribution that we (hopefully) will use at some point.