runningstat

package
v0.0.0-...-c2e30b8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: NIST-PD-fallback Imports: 4 Imported by: 0

README

ndn-dpdk/core/runningstat

This package implements Knuth and Welford's method for computing the standard deviation. Compared to the original RunningStats C++ class, this implementation does not support skewness and kurtosis, adds tracking of the minimum and maximum values, and can be configured to periodically sample the input instead of sampling every input.

To add an input, use the C function RunningStat_Push, or RunningStat_Push1 when minimum and maximum are unnecessary. To compute the average and standard deviation, use the Go type RunningStat.

Documentation

Overview

Package runningstat implements Knuth and Welford's method for computing the standard deviation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RunningStat

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

RunningStat collects statistics and allows computing min, max, mean, and variance. Algorithm comes from https://www.johndcook.com/blog/standard_deviation/ .

func FromPtr

func FromPtr(ptr unsafe.Pointer) (s *RunningStat)

FromPtr converts *C.RunningStat to RunningStat.

func New

func New() (s *RunningStat)

New constructs a new RunningStat instance in Go memory.

func (*RunningStat) Clear

func (s *RunningStat) Clear(enableMinMax bool)

Clear deletes collects data.

func (*RunningStat) Push

func (s *RunningStat) Push(x float64)

Push adds an input.

func (*RunningStat) Read

func (s *RunningStat) Read() (o Snapshot)

Read returns current counters as Snapshot.

func (*RunningStat) SetSampleRate

func (s *RunningStat) SetSampleRate(q int)

SetSampleRate changes sample rate be once every 2^q inputs.

type Snapshot

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

Snapshot contains a snapshot of RunningStat reading.

func (Snapshot) Add

func (s Snapshot) Add(o Snapshot) (sum Snapshot)

Add combines stats with another instance.

func (Snapshot) Count

func (s Snapshot) Count() uint64

Count returns number of inputs.

func (Snapshot) Len

func (s Snapshot) Len() uint64

Len returns number of samples.

func (Snapshot) MarshalJSON

func (s Snapshot) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (Snapshot) Max

func (s Snapshot) Max() float64

Max returns maximum value, if enabled.

func (Snapshot) Mean

func (s Snapshot) Mean() float64

Mean returns mean value.

func (Snapshot) Min

func (s Snapshot) Min() float64

Min returns minimum value, if enabled.

func (Snapshot) Scale

func (s Snapshot) Scale(ratio float64) (o Snapshot)

Scale multiplies every number by a ratio.

func (Snapshot) Stdev

func (s Snapshot) Stdev() float64

Stdev returns standard deviation of samples.

func (Snapshot) Sub

func (s Snapshot) Sub(o Snapshot) (diff Snapshot)

Sub subtracts stats in another instance.

func (*Snapshot) UnmarshalJSON

func (s *Snapshot) UnmarshalJSON(p []byte) (e error)

UnmarshalJSON implements json.Unmarshaler interface.

func (Snapshot) Variance

func (s Snapshot) Variance() float64

Variance returns variance of samples.

Jump to

Keyboard shortcuts

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