Documentation
¶
Overview ¶
Package interpolator provides interpolators to perform numerical interpolator for univariate data.
Index ¶
Examples ¶
- Geometric.Gradient
- Geometric.Value
- GeometricSqrt.Gradient
- GeometricSqrt.Value
- PiecewiseConstant.Gradient
- PiecewiseConstant.Value
- PiecewiseLinear.Gradient
- PiecewiseLinear.Value
- PiecewiseLinearSqrt.Gradient
- PiecewiseLinearSqrt.Value
- PiecewiseLinearThreshold.Gradient
- PiecewiseLinearThreshold.Value
- XYs.Interval
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Geometric ¶
type Geometric struct {
// contains filtered or unexported fields
}
Geometric is a classic geometric interpolator.
func NewGeometric ¶
NewGeometric builds a geometric interpolator. The input `xys` must be ordered, have unique abscissas and positive ordinates.
func (Geometric) Gradient ¶
Gradient computes the gradient of f(x) based on geometric interpolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewGeometric(xys)
if err != nil {
return
}
fmt.Printf("%0.4f\n", interp.Gradient(0.75))
Output: 0.7962
type GeometricSqrt ¶
type GeometricSqrt struct {
// contains filtered or unexported fields
}
GeometricSqrt performs a geometric interpolation with respect to the square root of the abscissae.
func NewGeometricSqrt ¶
func NewGeometricSqrt(xys XYs) (*GeometricSqrt, error)
NewGeometricSqrt builds a geometric sqrt interpolator. The input `xys` must be ordered, have unique abscissas and positive ordinates.
func (GeometricSqrt) Gradient ¶
func (interp GeometricSqrt) Gradient(x float64) float64
Gradient computes the gradient of f(x) based on geometric sqrt interpolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewGeometricSqrt(xys)
if err != nil {
return
}
fmt.Printf("%0.4f\n", interp.Gradient(0.75))
Output: 0.6037
func (GeometricSqrt) Value ¶
func (interp GeometricSqrt) Value(x float64) float64
Value compute the value of f(x) based on geometric sqrt interpolation with flat extrapolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewGeometricSqrt(xys)
if err != nil {
return
}
fmt.Printf("%0.4f\n", interp.Value(0.75))
Output: 1.2686
type PiecewiseConstant ¶
type PiecewiseConstant struct {
// contains filtered or unexported fields
}
PiecewiseConstant is a classic piecewise constant cadlag interpolator.
func NewPiecewiseConstant ¶
func NewPiecewiseConstant(xys XYs) (*PiecewiseConstant, error)
NewPiecewiseConstant builds a piecewise constant interpolator. The input `xys` must be ordered and have unique abscissas.
func (PiecewiseConstant) Gradient ¶
func (interp PiecewiseConstant) Gradient(x float64) float64
Gradient computes the gradient of f(x) based on piecewise constant interpolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseConstant(xys)
if err != nil {
return
}
fmt.Println(interp.Gradient(0.75))
Output: 0
func (PiecewiseConstant) Value ¶
func (interp PiecewiseConstant) Value(x float64) float64
Value compute the value of f(x) based on piecewise constant interpolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseConstant(xys)
if err != nil {
return
}
fmt.Println(interp.Value(0.75))
Output: 1
type PiecewiseLinear ¶
type PiecewiseLinear struct {
// contains filtered or unexported fields
}
PiecewiseLinear is a classic piecewise linear interpolator.
func NewPiecewiseLinear ¶
func NewPiecewiseLinear(xys XYs) (*PiecewiseLinear, error)
NewPiecewiseLinear builds a piecewise linear interpolator.
func (PiecewiseLinear) Gradient ¶
func (interp PiecewiseLinear) Gradient(x float64) float64
Gradient computes the gradient of f(x) based on linear interpolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseLinear(xys)
if err != nil {
return
}
fmt.Printf("%0.1f\n", interp.Gradient(0.75))
Output: 0.8
func (PiecewiseLinear) Value ¶
func (interp PiecewiseLinear) Value(x float64) float64
Value compute the value of f(x) based on piecewise linear interpolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseLinear(xys)
if err != nil {
return
}
fmt.Println(interp.Value(0.75))
Output: 1.2
type PiecewiseLinearSqrt ¶
type PiecewiseLinearSqrt struct {
// contains filtered or unexported fields
}
PiecewiseLinearSqrt performs a piecewise linear interpolation with respect to the square root of the abscissae.
func NewPiecewiseLinearSqrt ¶
func NewPiecewiseLinearSqrt(xys XYs) (*PiecewiseLinearSqrt, error)
NewPiecewiseLinearSqrt builds a piecewise linear sqrt interpolator with flat extrapolation. The input `xys` must be ordered and have unique abscissas.
func (PiecewiseLinearSqrt) Gradient ¶
func (interp PiecewiseLinearSqrt) Gradient(x float64) float64
Gradient computes the gradient of f(x) based on piecewise linear interpolation with flat extrapolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseLinearSqrt(xys)
if err != nil {
return
}
fmt.Println(interp.Gradient(1.5))
Output: 0
func (PiecewiseLinearSqrt) Value ¶
func (interp PiecewiseLinearSqrt) Value(x float64) float64
Value compute the value of f(x) based on piecewise linear interpolation with flat extrapolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseLinearSqrt(xys)
if err != nil {
return
}
fmt.Println(interp.Value(1.5))
Output: 1.4
type PiecewiseLinearThreshold ¶
type PiecewiseLinearThreshold struct {
// contains filtered or unexported fields
}
PiecewiseLinearThreshold is a piecewise linear interpolator that extrapolates a threshold value.
func NewPiecewiseLinearThreshold ¶
func NewPiecewiseLinearThreshold(xys XYs) (*PiecewiseLinearThreshold, error)
NewPiecewiseLinearThreshold builds a piecewise linear interpolator with flat extrapolation. The input `xys` must be ordered and have unique abscissas.
func (PiecewiseLinearThreshold) Gradient ¶
func (interp PiecewiseLinearThreshold) Gradient(x float64) float64
Gradient computes the gradient of f(x) based on piecewise linear interpolation with flat extrapolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseLinearThreshold(xys)
if err != nil {
return
}
fmt.Println(interp.Gradient(1.5))
Output: 0
func (PiecewiseLinearThreshold) Value ¶
func (interp PiecewiseLinearThreshold) Value(x float64) float64
Value compute the value of f(x) based on piecewise linear interpolation with flat extrapolation.
Example ¶
xys := XYs{
{
X: 0.0,
Y: 1.2,
},
{
X: 0.5,
Y: 1.0,
},
{
X: 1.0,
Y: 1.4,
},
}
interp, err := NewPiecewiseLinearThreshold(xys)
if err != nil {
return
}
fmt.Println(interp.Value(1.5))
Output: 1.4
type XYs ¶
type XYs []XY
XYs represents a slice of data points.
