Skip to content

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.

License

Notifications You must be signed in to change notification settings

axiomhq/variance

Repository files navigation

variance: Variance and standard deviation calculation using variance's algorithm variance: Variance and standard deviation calculation using variance's algorithm

Go Reference Workflow Latest Release License

Axiom unlocks observability at any scale.

  • Ingest with ease, store without limits: Axiom's next-generation datastore enables ingesting petabytes of data with ultimate efficiency. Ship logs from Kubernetes, AWS, Azure, Google Cloud, DigitalOcean, Nomad, and others.
  • Query everything, all the time: Whether DevOps, SecOps, or EverythingOps, query all your data no matter its age. No provisioning, no moving data from cold/archive to "hot", and no worrying about slow queries. All your data, all. the. time.
  • Powerful dashboards, for continuous observability: Build dashboards to collect related queries and present information that's quick and easy to digest for you and your team. Dashboards can be kept private or shared with others, and are the perfect way to bring together data from different sources.

For more information check out the official documentation and our community Discord.

Introduction

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

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.

-- Updating mean and variance estimates: an improved method - D. H. D. West

It features merging of several multiple sets of statistics and adding weighted values.

Quickstart

Install using go get:

go get github.com/axiomhq/variance

Import the package:

import "github.com/axiomhq/variance"

Use the package:

package main

import (
 "fmt"

 "github.com/axiomhq/variance"
)

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

 stats1.Add(1)
 stats1.Add(1)
 stats1.Add(1)
 stats1.Add(0)
 stats1.Add(0)
 stats1.Add(0)

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

Checkout the example or run it on pkg.go.dev.

License

Distributed under the MIT License.

About

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.

Topics

Resources

License

Stars

Watchers

Forks