JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.
Other
1.11k stars 418 forks source link

Bug in variance and standard deviation of multivariate t distribution #337

Open afniedermayer opened 9 years ago

afniedermayer commented 9 years ago
using Distributions
td=Distributions.DiagTDist(3.0,[0.,0.],sqrt([1.,4.]))
println(var(td))
println(std(td))

outputs

[3.0,12.0]
ERROR: `start` has no method matching start(::GenericMvTDist{PDiagMat})
 in var at statistics.jl:42

instead of

[1.0,4.0]
[1.0,2.0]
afniedermayer commented 9 years ago

I currently use the workaround

degrees_of_freedom = 3.0
td=Distributions.DiagTDist(degrees_of_freedom, [0.,0.], sqrt([1.,4.]/degrees_of_freedom))

to get a distribution with the covariance matrix [1 0 0 4] Either the constructor of DiagTDist and IsoTDist or the functions calculating var and std should be fixed.