Statistics.jl
Statistics.jl copied to clipboard
`cov`/`cor` with dims>2 should error?
I found this a little surprsing. Should this error rather than give NaN
s?
> using Statistics
> A = rand(3, 5)
> cov(A, dims=7)
3×3 Array{Float64,2}:
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
> cor(A, dims=7)
3×3 Array{Float64,2}:
1.0 NaN NaN
NaN 1.0 NaN
NaN NaN 1.0
(Julia 1.1.1)
On Slack
Milan Bouchet-Valat I guess this behavior is inherited from reductions like
sum
, where higher dimensions are ignored (they are collapsed, which is a no-op). But I'm not sure it makes sense here. File an issue?
It doesn’t help that the ˋcorrected = trueˋ version of ˋcovˋ which is applied multiplies everything with ˋNaN == 1/(n-1)ˋ