I have a series of variables corresponding to some physical parameters for which I use a normal distribution. Apart from having a cleaner code, I was wondering whether it’s more efficient to use the shape option in the distribution rather than multiple independent distributions? Right now, I have a series of them, with different names but with the same mu and sigma.
Hard to tell without much details, but yes we usually advise using
shape to vectorize high-dimensional random variables, as detailed in the quickstart for instance.
Hope this helps
Building on Alex’s answer, here’s a small numerical experiment to try for yourself to compare sampling rates. I got a factor of 4x improvement for a vectorized variable.
Thanks both, that’s useful (and convincing…!)