Hi Julia community!
I’m trying to implement the Random.rand
function for a custom distribution.
That distribution can have different “event” sizes, meaning a single sample could be a scalar, a vector, or in general an n-dimensional array.
My goal is to implement Random.rand(custom_dist, dims)
in such a way, that it always produces an array of size (eventsize..., dims...)
.
For example if my distribution has an event size of (4,), meaning a single sample is a vector of length 4 and I call Random.rand(CustomDist(eventsize=(4,)), (2, 3)
, I want the result to be an array of size (4, 2, 3)
.
Does the Random API provide this? I’ve read the documentation multiple times but still don’t feel like I really get it. At first I thought the last argument to Sampler
allowed me to hook into the dims
parameter, but it seems to be just a flag specifying if one or multiple values should be generated.
Distributions.jl does implement something close for their multivariate and matrixvariate distributions, however it only works correctly when dims is an integer.
Any ideas?