onlinestats

package module
v0.0.0-...-01b4d81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2021 License: MIT Imports: 5 Imported by: 38

Documentation

Overview

Package onlinestats provides online, one-pass algorithms for descriptive statistics.

The implementation is based on the public domain code available at http://www.johndcook.com/skewness_kurtosis.html .

The linear regression code is from http://www.johndcook.com/running_regression.html .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KS

func KS(data1, data2 []float64) float64

KS performs a Kolmogorov-Smirnov test for the two datasets, and returns the p-value for the null hypothesis that the two sets come from the same distribution.

func MannWhitney

func MannWhitney(xs, ys []float64) float64

MannWhitney performs a Matt-Whitney U test for the two samples xs and ys. It returns the two-tailed p-value for the null hypothesis that the medians of the two samples are the same. This uses the normal approximation which is more accurate if the number of samples is >30.

func Mean

func Mean(a []float64) float64

func Pearson

func Pearson(a, b []float64) float64

func SWilk

func SWilk(x []float64) (float64, float64, error)

func SampleStddev

func SampleStddev(a []float64) float64

func SampleVariance

func SampleVariance(a []float64) float64

func Spearman

func Spearman(data1, data2 []float64) (rs float64, p float64)

Spearman returns the rank correlation coefficient between data1 and data2, and the associated p-value

func Sum

func Sum(a []float64) float64

func SumSq

func SumSq(a []float64) float64

func SwilkCoeffs

func SwilkCoeffs(n int) []float64

Precomputes the coefficients array a for SWilk

func Tukey

func Tukey(data []float64) []float64

Tukey returns the slice (sorted) with all the 1.5 IQR outliers removed

func Variance

func Variance(a []float64) float64

func Welch

func Welch(xs, ys Stats) float64

Welch implements a Welch's t-test. Returns the probability that the difference in means is due to chance.

Types

type DEA

type DEA struct {
	// contains filtered or unexported fields
}

http://www.drdobbs.com/tools/discontiguous-exponential-averaging/184410671

func NewDEA

func NewDEA(alpha float64, maxDt float64) *DEA

func (*DEA) CompletenessFraction

func (ew *DEA) CompletenessFraction(t float64) float64

func (*DEA) Mean

func (ew *DEA) Mean() float64

func (*DEA) Stddev

func (ew *DEA) Stddev() float64

func (*DEA) Update

func (ew *DEA) Update(newData float64, t float64)

func (*DEA) Var

func (ew *DEA) Var() float64

type ExpWeight

type ExpWeight struct {
	// contains filtered or unexported fields
}

func NewExpWeight

func NewExpWeight(alpha float64) *ExpWeight

func (*ExpWeight) Len

func (e *ExpWeight) Len() int

func (*ExpWeight) Mean

func (e *ExpWeight) Mean() float64

func (*ExpWeight) Push

func (e *ExpWeight) Push(x float64)

func (*ExpWeight) Stddev

func (e *ExpWeight) Stddev() float64

func (*ExpWeight) Var

func (e *ExpWeight) Var() float64

type Regression

type Regression struct {
	// contains filtered or unexported fields
}

func CombineRegressions

func CombineRegressions(a, b Regression) *Regression

func NewRegression

func NewRegression() *Regression

func (*Regression) Correlation

func (r *Regression) Correlation() float64

func (*Regression) Intercept

func (r *Regression) Intercept() float64

func (*Regression) Len

func (r *Regression) Len() int

func (*Regression) Push

func (r *Regression) Push(x, y float64)

func (*Regression) Slope

func (r *Regression) Slope() float64

type Reservoir

type Reservoir struct {
	// contains filtered or unexported fields
}

func NewReservoir

func NewReservoir(capacity int) *Reservoir

func (*Reservoir) Len

func (r *Reservoir) Len() int

func (*Reservoir) Mean

func (r *Reservoir) Mean() float64

func (*Reservoir) Push

func (r *Reservoir) Push(n float64)

func (*Reservoir) Stddev

func (r *Reservoir) Stddev() float64

func (*Reservoir) Var

func (r *Reservoir) Var() float64

type Running

type Running struct {
	// contains filtered or unexported fields
}

func CombineRunning

func CombineRunning(a, b *Running) *Running

func NewRunning

func NewRunning() *Running

func (*Running) Kurtosis

func (r *Running) Kurtosis() float64

func (*Running) Len

func (r *Running) Len() int

func (*Running) Mean

func (r *Running) Mean() float64

func (*Running) Push

func (r *Running) Push(x float64)

func (*Running) Skewness

func (r *Running) Skewness() float64

func (*Running) Stddev

func (r *Running) Stddev() float64

func (*Running) Var

func (r *Running) Var() float64

type Stats

type Stats interface {
	Mean() float64
	Var() float64
	Len() int
}

type SwilkFault

type SwilkFault int

func (SwilkFault) Error

func (s SwilkFault) Error() string

type WindExp

type WindExp struct {
	// contains filtered or unexported fields
}

WindExp maintains a window of values, followed by a exponentially-weighted region for the items that have left the window. This is similar to the Average Loss Interval from "Equation-Based Congestion Control for Unicast Applications" ( http://www.icir.org/tfrc/tcp-friendly.pdf ), but with lower update cost. The advantage is that this maintains more local history, but doesn't have the large changes when items leave the window.

func NewWindExp

func NewWindExp(capacity int, alpha float64) *WindExp

NewWindExp returns WindExp with the specified window capacity and exponential alpha

func (*WindExp) Len

func (we *WindExp) Len() int

func (*WindExp) Mean

func (we *WindExp) Mean() float64

func (*WindExp) Push

func (we *WindExp) Push(n float64)

func (*WindExp) Stddev

func (we *WindExp) Stddev() float64

func (*WindExp) Var

func (we *WindExp) Var() float64

type Windowed

type Windowed struct {
	// contains filtered or unexported fields
}

func NewWindowed

func NewWindowed(capacity int) *Windowed

func (*Windowed) Len

func (w *Windowed) Len() int

func (*Windowed) Mean

func (w *Windowed) Mean() float64

func (*Windowed) Push

func (w *Windowed) Push(n float64) float64

func (*Windowed) Set

func (w *Windowed) Set(data []float64)

Set sets the current windowed data. The length is reset, and Push() will start overwriting the first element of the array.

func (*Windowed) Stddev

func (w *Windowed) Stddev() float64

func (*Windowed) Var

func (w *Windowed) Var() float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL