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 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 ¶
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 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.