util

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MovingWindow

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

MovingWindow is a moving window

func NewMovingWindow

func NewMovingWindow(size int) *MovingWindow

func (*MovingWindow) Cap

func (mw *MovingWindow) Cap() int

Cap returns max size of window

func (*MovingWindow) Drop

func (mw *MovingWindow) Drop(count int) (mean float64, stddev float64)

Drop removes count values from the window.

func (*MovingWindow) Len

func (mw *MovingWindow) Len() int

Len returns how many items in the window

func (*MovingWindow) Mean

func (mw *MovingWindow) Mean() float64

Mean is the moving window average

func (*MovingWindow) Recalculate added in v1.8.5

func (mw *MovingWindow) Recalculate() (mean float64, stddev float64)

func (*MovingWindow) Stats

func (mw *MovingWindow) Stats() (mean float64, stddev float64)

Stats returns the statistics of this window

func (*MovingWindow) StdDev

func (mw *MovingWindow) StdDev() float64

StdDev is the moving average std

func (*MovingWindow) Update

func (mw *MovingWindow) Update(value float64) (mean float64, stddev float64)

Update adds the new value to the moving window, returns average and stddev. If the window is full, the oldest value will be removed and the new value is added. Returns calculated Average and Standard Deviation.

Jump to

Keyboard shortcuts

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