Go implementation Welford’s method for one-pass variance computation

GoDoc

Welford - Online method of calculating variance and standard deviation

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

Highlights:

  • Merging of several multiple sets of statistics
  • Add weighted values

Abstract

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.

Example Usage

0.5 variance := s.Variance() // ==> 0.3 stdev := s.StandardDeviation() // ==> 0.5477225575051661 variancp := s.VariancePpopulation() // ==> 0.25 stdevp := s.StandardDeviationPopulation() // ==> 0.5 n := s.NumDataValues()) // ==> 6 sts2 := welford.New() sts2.Add(3) sts1.Merge(sts2) // merge sts1 into sts2 sts2.Clear() // resets the state os sts2 } ">
package welford_example

import "github.com/axiomhq/welford"

func Example() {
  sts1 := welford.New()
  sts1.Add(1)
  sts1.Add(1)
  sts1.Add(1)
  sts1.Add(0)
  sts1.Add(0)
  sts1.Add(0)

  mean := s.Mean() // ==> 0.5
  variance := s.Variance() // ==> 0.3
  stdev := s.StandardDeviation() // ==> 0.5477225575051661
  variancp := s.VariancePpopulation()	// ==> 0.25
  stdevp := s.StandardDeviationPopulation() // ==> 0.5
  n := s.NumDataValues()) // ==> 6

  sts2 := welford.New()
  sts2.Add(3)

  sts1.Merge(sts2) // merge sts1 into sts2

  sts2.Clear() // resets the state os sts2
}
Similar Resources

Optimal implementation of ordered maps for Golang - ie maps that remember the order in which keys were inserted.

Goland Ordered Maps Same as regular maps, but also remembers the order in which keys were inserted, akin to Python's collections.OrderedDicts. It offe

Jan 3, 2023

An idiomatic Go implementation of Leaky bucket.

lbucket lbucket is an idiomatic Go leaky bucket implementation. The library make use of plain old Go stdlib; in other words, there are no third-party

Apr 17, 2022

A faster RWLock primitive in Go, 2-3 times faster than RWMutex. A Go implementation of concurrency control algorithm in paper Left-Right - A Concurrency Control Technique with Wait-Free Population Oblivious Reads

Go Left Right Concurrency A Go implementation of the left-right concurrency control algorithm in paper Left-Right - A Concurrency Control Technique w

Jan 6, 2023

Go implementation of the geodesic routines from GeographicLib

Go implementation of the geodesic routines from GeographicLib

geodesic This package is a Go implementation of the geodesic routines from GeographicLib. Features Pure Go implementation Distance calculations with n

Dec 23, 2022

go-logr implementation with pterm

go-logr implementation with pterm

plogr go-logr implementation with pterm Usage See examples Add more colors and levels By default, only level 0 (info) and level 1 (debug) are supporte

Dec 22, 2021

Reference go implementation of globaldce protocol

globaldce-go This is the reference implementation of the command line interface of globaldce coded in the go programming language. This project is sti

Nov 8, 2021

Sliding window counters Redis rate limiting implementation for Golang

Sliding window counters Redis rate limiting implementation for Golang (Based on the Figma API rate limit algorithm)

Dec 21, 2022

Generic Free List implementation to reuse memory and avoid allocations

gofl GOFL provides a Generic Free List implementation for Go. Installation This

Oct 17, 2022

yaml-patch is a version of Evan Phoenix's json-patch, which is an implementation of JSON Patch, directly transposed to YAML

yaml-patch yaml-patch is a version of Evan Phoenix's json-patch, which is an implementation of JavaScript Object Notation (JSON) Patch, directly trans

Jan 15, 2022
Related tags
Reload Go code in a running process at function/method level granularity

got reload? Function/method-level stateful hot reloading for Go! Status Very much work in progress.

Nov 9, 2022
Tugas Alta Immersive Backend Golang Fundamental Programming (Pointer, Struct, Method, Interface)
Tugas Alta Immersive Backend Golang Fundamental Programming (Pointer, Struct, Method, Interface)

Tatacara Melakukan Setup Tugas clone project ini dengan cara git clone https://github.com/Immersive-Backend-Resource/Pointer-Struct-Method-Interface.g

Jan 9, 2022
safe and easy casting from one type to another in Go

cast Easy and safe casting from one type to another in Go Don’t Panic! ... Cast What is Cast? Cast is a library to convert between different go types

Jan 1, 2023
The one-stop shop for most common Go functions
The one-stop shop for most common Go functions

Pandati The one stop shop for most common Go functions Table of contents Pandati The one stop shop for most common Go functions Table of contents Purp

Mar 21, 2022
A fully Go userland with Linux bootloaders! u-root can create a one-binary root file system (initramfs) containing a busybox-like set of tools written in Go.

u-root Description u-root embodies four different projects. Go versions of many standard Linux tools, such as ls, cp, or shutdown. See cmds/core for m

Dec 29, 2022
📚 Clone all your repositories from GitHub with one command!

An utility to clone easily all your repositories from GitHub. The process is done concurrently so it is quite fast.

Apr 6, 2022
go implementation of timsort

timsort timsort is a Go implementation of Tim Peters's mergesort sorting algorithm. For many input types it is 2-3 times faster than Go's built-in sor

Nov 7, 2022
Implementation of do255e and do255s in Go

Go Implementation of do255e and do255s This is a plain Go implementation of do255e and do255s. It is considered secure; all relevant functions should

Aug 15, 2022
Go implementation of the Heaven's Gate technique
Go implementation of the Heaven's Gate technique

gopherheaven is a Go implementation of the classic Heaven's Gate technique originally published by roy g biv on VX Heaven in 2009. gopherheaven can be used as an evasion technique to directly call 64-bit code from a 32-bit process.

Dec 20, 2022
Lightweight, Simple, Quick, Thread-Safe Golang Stack Implementation

stack Lightweight, Simple, Quick, Thread-Safe Golang Stack Implementation Purpose Provide a fast, thread safe, and generic Golang Stack API with minim

May 3, 2022