ewma

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EWMA

type EWMA interface {
	// Add adds a new value to the EWMA
	Add(float64)
	// Get returns the current value of the EWMA
	Get() float64
	// Reset resets the EWMA to the initial value
	Reset()
	// Set sets the EWMA to the given value
	Set(float64)
}

EWMA is the interface for Exponentially Weighted Moving Average It is used to calculate the moving average with decay of a series of numbers

type SimpleEWMA

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

SimpleEWMA is a simple implementation of EWMA

func NewSimpleEWMA

func NewSimpleEWMA(alpha ...float64) *SimpleEWMA

NewSimpleEWMA returns a new SimpleEWMA If the alpha is not provided we use a default value of constDecayFactor If the alpha is provided we calulate the smoothing factor from it

func (*SimpleEWMA) Add

func (s *SimpleEWMA) Add(value float64)

Add adds a new value to the EWMA

func (*SimpleEWMA) Get

func (s *SimpleEWMA) Get() float64

Get returns the current value of the EWMA

func (*SimpleEWMA) Reset

func (s *SimpleEWMA) Reset()

Reset resets the EWMA to the initial value

func (*SimpleEWMA) Set

func (s *SimpleEWMA) Set(value float64)

Set sets the EWMA to the given value

Jump to

Keyboard shortcuts

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