ewma

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rate

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

Rate is an exponentially weighted moving average event rate. The rate is always calculated per second and samples are summed up within the second duration.

func New

func New(lifetime time.Duration) *Rate

New creates a new rate with a given lifetime.

lifetime is the time required for the decaying quantity to reduced to 1⁄e ≈ 0.367879441 times its initial value.

func NewHalfLife

func NewHalfLife(halflife time.Duration) *Rate

NewHalfLife creates a new rate with a given half-life.

halflife is the time required for the decaying quantity to fall to one half of its initial value.

func (*Rate) LastUpdate

func (r *Rate) LastUpdate() time.Time

func (*Rate) Update

func (r *Rate) Update(v float64)

func (*Rate) UpdateAt

func (r *Rate) UpdateAt(v float64, t int64)

func (*Rate) Value

func (r *Rate) Value() float64

func (*Rate) ValueAt

func (r *Rate) ValueAt(t int64) float64

Jump to

Keyboard shortcuts

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