statistic

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataPoint

type DataPoint struct {
	Timestamp time.Time
	Value     float64
}

DataPoint represents a single data point in a time series.

type Statistic added in v0.0.20

type Statistic struct {
	Data []DataPoint
}

Statistic is a generic structure to hold time series data.

func (*Statistic) Add added in v0.0.20

func (s *Statistic) Add(ts time.Time, value float64)

Add appends a new data point to the series.

func (*Statistic) Max added in v0.0.20

func (s *Statistic) Max() (float64, error)

Max returns the maximum value in the data set.

func (*Statistic) Min added in v0.0.20

func (s *Statistic) Min() (float64, error)

Min returns the minimum value in the data set.

func (*Statistic) MovingAverage added in v0.0.20

func (s *Statistic) MovingAverage(windowSize int) ([]float64, error)

MovingAverage calculates the moving (or rolling) average for the data points, using the specified window size. The returned slice is aligned with the data slice.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳