timeseries

package module
v0.0.0-...-addb771 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2018 License: MIT Imports: 3 Imported by: 0

README

timeseries

Build Status

Package timeseries provides utilities to manipulate and analyze timeseries data. For compatability with Gonum, a Timeseries is simply a pair of float64 slices, representing the X and the Y axis. You can manipulate them as you wish, but ensure two things:

  • Many of the methods in this library assume that the data is sorted. If you do not insert in sorted order, ensure that you call Sort()

  • Ensure that Timeseries.Xs and Timeseries.Ys is always of equal length if you manipulate them without the accessors provided. Violating this constraint will result in pancis.

At the time of this writing(May, 2018), please do not assume API stability.

License

timeseries is licensed under MIT. See LICENSE

Documentation

Overview

Package timeseries provides utilities to manipulate and analyze timeseries data. For compatability with Gonum, a Timeseries is simply a pair of float64 slices, representing the X and the Y axis. You can manipulate them as you wish, but ensure two things:

  • Many of the methods in this library assume that the data is sorted. If you do not insert in sorted order, ensure that you call Sort()
  • Ensure that Timeseries.Xs and Timeseries.Ys is always of equal length if you manipulate them without the accessors provided

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Timeseries

type Timeseries struct {
	Xs []float64
	Ys []float64
}

func (Timeseries) After

func (t Timeseries) After(x float64) Timeseries

After - Return a shallow copy of the items in the time series having Xs >= x The series must be sorted.

func (*Timeseries) Append

func (t *Timeseries) Append(x float64, y float64)

Append - Append value @ time to the timeseries Note that you might need a sort if you're inserting points out-of-order

func (Timeseries) At

func (t Timeseries) At(i int) (x, y float64)

At - return the x, y pair at index i If i does not represent a valid index, At panics

func (Timeseries) Before

func (t Timeseries) Before(x float64) Timeseries

Before - Return a shallow copy of the items in the time series having Xs < x. The series must be sorted.

func (Timeseries) Between

func (t Timeseries) Between(x1, x2 float64) Timeseries

Between - Return a shallow copy of the items in the time series between [x1, x2)

func (Timeseries) Difference

func (t Timeseries) Difference() (ret Timeseries)

Difference the timeseries N, returning a new series of length len(N)-1

func (Timeseries) Equal

func (t Timeseries) Equal(other Timeseries) bool

Equal - Return true if t and other represent the same time series

func (Timeseries) First

func (t Timeseries) First() (x, y float64)

First - Return the first x, y value of the timeseries. If the timeseries contains no items, First() panics.

func (Timeseries) Last

func (t Timeseries) Last() (x, y float64)

Last - Return the last x, y value of the timeseries. If the timeseries contains no items, Last() panics.

func (Timeseries) Len

func (t Timeseries) Len() int

Len - return the lenght of the timeseries. If len(Timeseries.Xs) != len(Timeseries.Ys), Len() panics

func (Timeseries) Less

func (t Timeseries) Less(i, j int) bool

func (Timeseries) LinearRegression

func (t Timeseries) LinearRegression() (alpha, beta, rmse float64)

SimpleLinearRegression performs a simple linear regression of the series computing the best fit line

y = alpha + beta*x

such that rmse is minimized

func (Timeseries) MovingAverage

func (t Timeseries) MovingAverage(window int) (ret Timeseries)

MovingAverage returns a time series representing the window-sized moving average over t

func (Timeseries) Slice

func (t Timeseries) Slice(start, end int) Timeseries

Slice slices the Timeseries equivalently to t[start:end]

func (Timeseries) Sort

func (t Timeseries) Sort()

func (Timeseries) Swap

func (t Timeseries) Swap(i, j int)

func (Timeseries) WeightedLinearRegression

func (t Timeseries) WeightedLinearRegression(weights []float64) (alpha, beta, rmse float64)

WeightedLinearRegression performs a weighted linear regression of the series computing the best fit line

y = alpha + beta*x

such that rmse is minimized

Jump to

Keyboard shortcuts

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