SkillAgentSearch skills...

Variance

Go implementation of variance's method for one-pass variance computation with D. H. D. West improved methods which features merging of several multiple sets of statistics and adding weighted values.

Install / Use

/learn @axiomhq/Variance
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

variance Go Reference Workflow Latest Release License

Go implementation of Welford's method for one-pass variance computation with D. H. D. West improved methods.

Install

go get github.com/axiomhq/variance

Usage

package main

import (
    "fmt"

    "github.com/axiomhq/variance"
)

func main() {
    stats := variance.New()

    stats.Add(1)
    stats.Add(1)
    stats.Add(1)
    stats.Add(0)
    stats.Add(0)
    stats.Add(0)

    fmt.Println(
        stats.Mean(),
        stats.Variance(),
        stats.StandardDeviation(),
        stats.VariancePopulation(),
        stats.StandardDeviationPopulation(),
        stats.NumDataValues(),
    )
}

For more examples, check out the example or run it on pkg.go.dev.

Features

  • One-pass variance computation
  • Merging of multiple sets of statistics
  • Support for weighted values
  • Stable and accurate computation using D. H. D. West's improved method

Reference

A method of improved efficiency is given for updating the mean and variance of weighted sampled data when an additional data value is included in the set. Evidence is presented that the method is stable and at least as accurate as the best existing updating method.

-- <cite>Updating mean and variance estimates: an improved method - D. H. D. West</cite>

License

MIT

<!-- Badges -->
View on GitHub
GitHub Stars19
CategoryDevelopment
Updated4d ago
Forks7

Languages

Go

Security Score

95/100

Audited on Mar 30, 2026

No findings