Often we need to draw a number of samples from a distribution where that number might sometimes be 0: rand(d, 0). For custom multivariate distributions this throws an error. It seems to work for the built-in multivariate (e.g. MvNormal) and for custom univariate distributions.
using Distributions, Random
struct Foo <: Sampleable{Multivariate, Continuous} end
Base.length(::Foo) = 3
Base.eltype(::Foo) = Float64
Distributions._rand!(rng::AbstractRNG, ::Foo, x::AbstractVector{<:Real}) = Distributions.rand!(rng, x)
rand(Foo(), 0)
Often we need to draw a number of samples from a distribution where that number might sometimes be
0
:rand(d, 0)
. For custom multivariate distributions this throws an error. It seems to work for the built-in multivariate (e.g.MvNormal
) and for custom univariate distributions.