mitchelloharawild / distributional

Vectorised distributions for R
https://pkg.mitchelloharawild.com/distributional
GNU General Public License v3.0
94 stars 15 forks source link

Add `posterior::rvar()` functionality #27

Open mitchelloharawild opened 4 years ago

mitchelloharawild commented 4 years ago

From #24, requires implementing #25 first.

mitchelloharawild commented 2 years ago

@mjskay I've been poking around with posterior::rvar() a little bit, and wanted to know a bit more about what it does that distributional::dist_sample() can not (or more-so, the typical applications of an rvar).

distributional::dist_sample() can now handle samples from multivariate sources. If needed, I think it can be extended to support arbitrary array dimensions to allow for things like random matrices or random higher dimensional arrays. As far as I can tell, with some more generalisation of dimension support in dist_sample(), it should be capable of everything {rvar} objects are used for.

I've also reconsidered what you mentioned in https://github.com/mitchelloharawild/distributional/issues/24#issuecomment-641650799, and now think that it is most natural for {distributional} to use data structure (3). In fact this is what is being done in distributional::dist_sample() - I think I misunderstood the goals of <rvar> objects when thinking (1) was the preferred option in distributional, and got confused with how the package would handle vectors of <rvar>-like objects.