interp

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: BSD-3-Clause Imports: 3 Imported by: 8

README

Gonum interp GoDoc

Package interp is an interpolation package for the Go language.

Documentation

Overview

Package interp implements 1-dimensional algorithms for interpolating values. Outside of the interpolation interval determined by the interpolated data, the returned value is undefined (but we do our best to return something reasonable).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AkimaSpline

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

AkimaSpline is a piecewise cubic 1-dimensional interpolator with continuous value and first derivative, which can be fitted to (X, Y) value pairs without providing derivatives. See https://www.iue.tuwien.ac.at/phd/rottinger/node60.html for more details.

func (*AkimaSpline) Fit

func (as *AkimaSpline) Fit(xs, ys []float64) error

Fit fits a predictor to (X, Y) value pairs provided as two slices. It panics if len(xs) < 2, elements of xs are not strictly increasing or len(xs) != len(ys). Always returns nil.

func (*AkimaSpline) Predict

func (as *AkimaSpline) Predict(x float64) float64

Predict returns the interpolation value at x.

func (*AkimaSpline) PredictDerivative

func (as *AkimaSpline) PredictDerivative(x float64) float64

PredictDerivative returns the predicted derivative at x.

type Constant

type Constant float64

Constant predicts a constant value.

func (Constant) Predict

func (c Constant) Predict(x float64) float64

Predict returns the predicted value at x.

type DerivativePredictor

type DerivativePredictor interface {
	Predictor

	// PredictDerivative returns the predicted derivative at x.
	PredictDerivative(x float64) float64
}

DerivativePredictor predicts both the value and the derivative of a function. It handles both interpolation and extrapolation.

type FittablePredictor

type FittablePredictor interface {
	Fitter
	Predictor
}

FittablePredictor is a Predictor which can fit itself to data.

type Fitter

type Fitter interface {
	// Fit fits a predictor to (X, Y) value pairs provided as two slices.
	// It panics if len(xs) < 2, elements of xs are not strictly increasing
	// or len(xs) != len(ys). Returns an error if fitting fails.
	Fit(xs, ys []float64) error
}

Fitter fits a predictor to data.

type Function

type Function func(float64) float64

Function predicts by evaluating itself.

func (Function) Predict

func (fn Function) Predict(x float64) float64

Predict returns the predicted value at x by evaluating fn(x).

type PiecewiseConstant

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

PiecewiseConstant is a left-continous, piecewise constant 1-dimensional interpolator.

func (*PiecewiseConstant) Fit

func (pc *PiecewiseConstant) Fit(xs, ys []float64) error

Fit fits a predictor to (X, Y) value pairs provided as two slices. It panics if len(xs) < 2, elements of xs are not strictly increasing or len(xs) != len(ys). Always returns nil.

func (PiecewiseConstant) Predict

func (pc PiecewiseConstant) Predict(x float64) float64

Predict returns the interpolation value at x.

type PiecewiseCubic

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

PiecewiseCubic is a piecewise cubic 1-dimensional interpolator with continuous value and first derivative.

func (*PiecewiseCubic) FitWithDerivatives

func (pc *PiecewiseCubic) FitWithDerivatives(xs, ys, dydxs []float64)

FitWithDerivatives fits a piecewise cubic predictor to (X, Y, dY/dX) value triples provided as three slices. It panics if len(xs) < 2, elements of xs are not strictly increasing, len(xs) != len(ys) or len(xs) != len(dydxs).

func (*PiecewiseCubic) Predict

func (pc *PiecewiseCubic) Predict(x float64) float64

Predict returns the interpolation value at x.

func (*PiecewiseCubic) PredictDerivative

func (pc *PiecewiseCubic) PredictDerivative(x float64) float64

PredictDerivative returns the predicted derivative at x.

type PiecewiseLinear

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

PiecewiseLinear is a piecewise linear 1-dimensional interpolator.

func (*PiecewiseLinear) Fit

func (pl *PiecewiseLinear) Fit(xs, ys []float64) error

Fit fits a predictor to (X, Y) value pairs provided as two slices. It panics if len(xs) < 2, elements of xs are not strictly increasing or len(xs) != len(ys). Always returns nil.

func (PiecewiseLinear) Predict

func (pl PiecewiseLinear) Predict(x float64) float64

Predict returns the interpolation value at x.

type Predictor

type Predictor interface {
	// Predict returns the predicted value at x.
	Predict(x float64) float64
}

Predictor predicts the value of a function. It handles both interpolation and extrapolation.

Jump to

Keyboard shortcuts

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