model

package
v0.0.0-...-768eb72 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: AGPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockDiag

func BlockDiag(mats ...*mat.Dense) (b *mat.Dense)

BlockDiag creates a block diagonal matrix with the provided matrices running along its diagonal.

func DenseValues

func DenseValues(d *mat.Dense) (data []float64)

DenseValues extracts the row-major data from the provided dense matrix.

func Diag

func Diag(v []float64) (d []float64)

Diag returns the corresponding diagonal square matrix values given diag values.

func Eye

func Eye(r int) (m *mat.Dense, err error)

Eye returns the dimension r identity matrix.

func Harmonics

func Harmonics(min, max float64) []float64

Harmonics provides a consistent method for generating fourier harmonics for a stream, it does so by splitting harmonics into powers of 10.

Types

type Deterministic

type Deterministic struct {
	*mv.Normal
}

Deterministic is the type against which we apply deterministic model updates.

func NewDeterministic

func NewDeterministic(period float64) (d *Deterministic)

NewDeterministic creates and returns a Deterministic with a proper state prior.

func (*Deterministic) Forecast

func (d *Deterministic) Forecast(period float64, n int) (f []*uv.Normal)

Forecast returns a forecasted slice of normal RVs for this deterministic component.

func (*Deterministic) State

func (d *Deterministic) State() (k *kalman.State)

State returns the kalman filter State.

func (*Deterministic) System

func (d *Deterministic) System(noise, walk, period float64) (k *kalman.System)

System generates process and observation matrices for this linear system.

func (*Deterministic) Update

func (d *Deterministic) Update(noise, walk, period, val float64) (resid float64, err error)

Update performs a filter step against the deterministic state.

type History

type History []float64

History contains the last two observations for this stream, it is required to do covariance estimation in real time.

func (History) Update

func (h History) Update(v float64)

Update shifts the history one place down and adds a new value.

type Model

type Model struct {
	Deterministic *Deterministic
	Stochastic    *Stochastic
	RCE           *RCE
}

Model stores dynamic state about a stream.

func New

func New(period float64) (m *Model)

New initialises a model given a stream period.

func (*Model) Forecast

func (m *Model) Forecast(period float64, n int) (f []*uv.Normal)

Forecast returns a slice of Normally distributed predictions.

func (*Model) Update

func (m *Model) Update(period, val float64)

Update iterates the Model in response to an observed event.

type RCE

type RCE struct {
	Theta   *uv.InverseGamma
	Zeta    *uv.InverseGamma
	History History
}

RCE is a recursive covariance estimator for a local level kalman filter.

func NewRCE

func NewRCE() (r *RCE)

NewRCE constructs an RCE with appropriate priors for theta and zeta.

func (*RCE) Noise

func (r *RCE) Noise() float64

Noise returns the current noise covariance.

func (*RCE) Update

func (r *RCE) Update(v float64)

Update updates the covariance estimator.

func (*RCE) Walk

func (r *RCE) Walk() float64

Walk returns the current walk covariance.

type Stochastic

type Stochastic struct {
	*mv.Normal
}

Stochastic is the type against which we apply stochastic model updates.

func NewStochastic

func NewStochastic() (s *Stochastic)

NewStochastic returns a stochastic with a proper state prior.

func (*Stochastic) Forecast

func (s *Stochastic) Forecast(noise, walk float64, n int) (f []*uv.Normal)

Forecast returns a forecasted slice of normal RVs for this stochastic component.

func (*Stochastic) State

func (s *Stochastic) State() (k *kalman.State)

State returns the kalman filter State.

func (*Stochastic) System

func (s *Stochastic) System(noise, walk float64) (k *kalman.System)

System generates process and observation matrices for this linear system.

func (*Stochastic) Update

func (s *Stochastic) Update(noise, walk, val float64) (err error)

Update performs a filter step against the stochastic state.

Jump to

Keyboard shortcuts

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