Skip to content

rand(::MvLocationScale, sz...) is inconsistent for length(sz) > 1 #245

@penelopeysm

Description

@penelopeysm
julia> using AdvancedVI, Distributions; mv = MvLocationScale(zeros(2), 1.0, Normal());

julia> rand(mv)
2-element Vector{Float64}:
  1.1396187240493345
 -0.23614109843834447

julia> rand(mv, 3)
2×3 Matrix{Float64}:
 -0.843996   0.73772   -1.05117
  0.356957  -0.909233   0.829167

julia> rand(mv, 3, 4)
3×4 Matrix{Vector{Float64}}:
 [-0.138124, 0.335119]  [-1.36683, -0.0922746]  [-0.965939, -0.229622]  [1.70725, -0.243339]
 [1.20617, -0.659821]   [-0.0097997, -1.38867]  [0.460145, 0.352632]    [-0.785098, -1.82992]
 [0.726249, 2.11884]    [0.634132, 0.491341]    [0.718743, -0.603134]   [0.572106, -2.25754]

I would have expected either the second one to return a vector-of-vectors, or the last one to return a 2x3x4 array, but right now they're kind of inconsistent.

That said, while writing up this issue, I discovered that Distributions.MvNormal has exactly the same behaviour! So I'm not sure if this is an AdvancedVI issue per se...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions