We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a305f71 commit 4989950Copy full SHA for 4989950
1 file changed
src/observed/EM.jl
@@ -248,8 +248,13 @@ function em_step!(
248
mul!(Σ, μ, μ', -1, 1)
249
μ .+= μ₀
250
251
- # try to fix non-positive-definite Σ
252
- isnothing(min_eigval) || copyto!(Σ, trunc_eigvals(Σ, min_eigval))
+ StatsBase._symmetrize!(Σ) # correct numerical errors
+ if !isnothing(min_eigval)
253
+ # try to fix non-positive-definite Σ
254
+ reg_Σ = trunc_eigvals(Σ, min_eigval)
255
+ # if no truncation was done, reg_Σ will be the same object
256
+ (reg_Σ === Σ) || copyto!(Σ, reg_Σ)
257
+ end
258
259
return Σ, μ
260
end
0 commit comments