joshday / OnlineStats.jl

⚡ Single-pass algorithms for statistics
https://joshday.github.io/OnlineStats.jl/latest/
MIT License
831 stars 62 forks source link

Small fixes for `FitMvNormal` #257

Closed Crown421 closed 1 year ago

Crown421 commented 1 year ago

Hey,

working with MvNormal, I noticed that the mean, var, and cov function were not defined for FitMvNormal, even though they exist for FitNormal. This MR adds them.

Further, I noticed that in the edge cases that the same (exact) same value is added a few times, the fallback mean and variance were returned. With this MR the behaviour becomes:

julia> m = FitMvNormal(2)
FitMvNormal: n=0 | value=([0.0, 0.0], [-0.0 -0.0; -0.0 -0.0])

julia> a = rand(2)
2-element Vector{Float64}:
 0.5760181131344163
 0.5890715541785612

julia> for i in 1:5
       fit!(m, a)
       end

julia> m
FitMvNormal: n=5 | value=([0.576018, 0.589072], [0.0 0.0; 0.0 0.0])
joshday commented 1 year ago

Looks good to me. Thanks for the PR!

joshday commented 1 year ago

I'll merge when CI goes green.

Crown421 commented 1 year ago

It seems CI has passed except for the AppVeyor job, which seems to be broken?