Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gdkrmr opened this issue Nov 9, 2018 · 2 comments
Open

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

gdkrmr opened this issue Nov 9, 2018 · 2 comments

Comments

@gdkrmr
Copy link
Owner

gdkrmr commented Nov 9, 2018

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
@joshday
Copy link

joshday commented Nov 9, 2018

I haven't really done research into this...I just know it gets a little tricky combining the OnlineStats meaning of weight with the StatsBase meaning. Sorry, I don't think I can be much help here.

@gdkrmr
Copy link
Owner Author

gdkrmr commented Nov 9, 2018

No problem. I figured out how to translate some of the weight types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants