Skip to content

Inconsistency in MvNormal constructors, covariance or deviation #584

@dehann

Description

@dehann

Hi,

I'm using Distributions.jl in IncrementalInference.jl and found what looks to be inconsistent behavior when constructing MvNormals. One dimensional cases take deviation while higher dimensions almost always take covariance.

using Distributions
julia> Base.std(rand(Normal(0.0,100.0), 1000))
96.7377564234093

julia> Base.std(rand(MvNormal([0.0],[100.0]), 1000), 2)
1×1 Array{Float64,2}:
 103.241

julia> Base.std(rand(MvNormal([0.0;0.0],[100.0;10.0]), 1000), 2)
2×1 Array{Float64,2}:
 101.026 
  10.0854

julia> Base.std(rand(MvNormal([0.0;0.0],[[100.0;0.0]';[0.0;10.0]']), 1000), 2)
2×1 Array{Float64,2}:
 10.1583 
  3.18971

Notice the last call expects covariance where all others take standard deviation. Do we want to persist this behavior? I don't really mind(think it is worth fixing), but it's a bit confusing and cost me some time debugging.

Thanks for putting this package out there!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions