statistics

package
v0.0.0-...-1c5d739 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnequalArrays    = errors.New("coordinate arrays are of different lengths")
	ErrInsufficientData = errors.New("not enough data to make a prediction")
)
View Source
var (
	// LeastSquaresPredictor uses the ordinary least squares method of
	// estimation to predict future values
	LeastSquaresPredictor = &olsPredictor{}
)

Functions

func LeastSquares

func LeastSquares(xs, ys []float64) (m, b float64, err error)

LeastSquares calculates the slope and y-intercept of the line of best fit for the series of points represented as arrays of x- and y-coordinates using the Ordinary Least Squares method.

func Mean

func Mean(series []float64) float64

Mean calculates the mean of an array of floats

Types

type Predictor

type Predictor interface {
	// Predict uses the timestamp/value pairs passed in to predict the value at
	// time now+period
	Predict(period time.Duration, timestamps, values []float64) (float64, error)
}

Predictor represents a strategy for predicting a future value based on historic values

Jump to

Keyboard shortcuts

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