Skip to content

what is the best version of _merge! for Weighted Variance #5

@gdkrmr

Description

@gdkrmr

Sorry to bother you @joshday, I found a couple of formulae and I am not sure which one is the best formula for _merge!(WeightedVariance), I guess you already did some research on this:

    W = o.W + o2.W
    γ1 = o.W / W
    γ2 = o2.W / W

    μ = smooth(o.μ, o2_μ, γ2)

    o.σ2 =
        γ1 * ( o.σ2  + (o.μ - μ) ^ 2) +
        γ2 * (o2.σ2 + (o2.μ - μ) ^ 2)

    o.μ = μ
    o.W = W
    o.W2 += o2.W2
    W = o.W + o2.W
    γ1 = o.W / W
    γ2 = o2.W / W

    μ = smooth(o.μ, o2_μ, γ2)

     o.σ2 =
         γ1 * ( o.σ2 +  o.μ ^ 2) +
         γ2 * (o2.σ2 + o2.μ ^ 2) -
         μ ^ 2

    o.μ = μ
    o.W = W
    o.W2 += o2.W2
    μ = o.μ
    
    γ = o2.W / (o2.W + o.W)
    δ = o2.μ - o.μ
    
    o.σ2 = smooth(o.σ2, o2.σ2, γ) +^ 2) * γ * (1.0 - γ)
    o.μ = smooth(o.μ, o2.μ, γ)
    
    o.W += o2.W
    o.W2 += o2.W2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions