Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

Allocations when generating samples from MvNormal with full covariance matrix

Open FelixNoessler opened this issue 2 years ago • 0 comments

Hello,

thanks for creating the Distributions package!

I get 16 allocations when I want to generate random samples from a MvNormal with full covariance matrix. Apparently, there is also type instability problem. Is there a way to generate random samples with full covariance matrix without allocations?

Best, Felix

using Distributions
using Random

d = MvNormal([1.0, 1.0], [1.0 0.5; 0.5 1.0])
u = Array{Float64}(undef, 2)
@allocated rand!(d, u)
@profview_allocs rand!(d, u) sample_rate = 1

image

FelixNoessler avatar Oct 18 '23 12:10 FelixNoessler