Documentation ¶
Overview ¶
The Tideland Go Library numerics package contains some functions to support statistical analysis.
Index ¶
- func PackageVersion() version.Version
- type CubicSplineFunction
- type Function
- type LeastSquaresFunction
- func (lsf *LeastSquaresFunction) AppendPoint(x, y float64)
- func (lsf *LeastSquaresFunction) AppendPoints(points Points)
- func (lsf *LeastSquaresFunction) Eval(x float64) float64
- func (lsf *LeastSquaresFunction) EvalPoint(x float64) *Point
- func (lsf *LeastSquaresFunction) EvalPoints(fromX, toX float64, count int) Points
- type Point
- type Points
- func (ps Points) CubicSplineFunction() *CubicSplineFunction
- func (ps Points) LeastSquaresFunction() *LeastSquaresFunction
- func (ps Points) Len() int
- func (ps Points) Less(i, j int) bool
- func (ps Points) SearchNextIndex(x float64) int
- func (ps Points) String() string
- func (ps Points) Swap(i, j int)
- func (ps Points) XAt(idx int) float64
- func (ps Points) XDifference(idxA, idxB int) float64
- func (ps Points) XInRange(x float64) bool
- func (ps Points) YAt(idx int) float64
- func (ps Points) YDifference(idxA, idxB int) float64
- type PolynomialFunction
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackageVersion ¶
PackageVersion returns the version of the version package.
Types ¶
type CubicSplineFunction ¶
type CubicSplineFunction struct {
// contains filtered or unexported fields
}
CubicSplineFunction is a function based on polynamial functions and a set of points it is going through.
func NewCubicSplineFunction ¶
func NewCubicSplineFunction(points Points) *CubicSplineFunction
NewCubicSplineFunction creates a cubic spline function based on a set of points.
func (*CubicSplineFunction) Eval ¶
func (csf *CubicSplineFunction) Eval(x float64) float64
Eval evaluates the function for a given X value and returns the Y value.
func (*CubicSplineFunction) EvalPoint ¶
func (csf *CubicSplineFunction) EvalPoint(x float64) *Point
EvalPoint evaluates the function for a given X value and returns the result as a point.
func (*CubicSplineFunction) EvalPoints ¶
func (csf *CubicSplineFunction) EvalPoints(fromX, toX float64, count int) Points
EvalPoints evaluates the function for a range of X values and returns the result as a set of points.
type Function ¶
type Function interface { // Eval evaluates a function for the value x. Eval(x float64) float64 // EvalPoint evaluates a function for the value // x and returns the result as point. EvalPoint(x float64) *Point // EvalPoints evaluates the function count times // with values between fromX and toX. The result is // returned as a set of pints. EvalPoints(fromX, toX float64, count int) Points }
Function is the standard interface the nmerical functions have to implement.
type LeastSquaresFunction ¶
type LeastSquaresFunction struct {
// contains filtered or unexported fields
}
LeastSquaresFunction is a function for approximation.
func NewLeastSquaresFunction ¶
func NewLeastSquaresFunction(points Points) *LeastSquaresFunction
NewLeastSquaresFunction creates a new least squares function based on a set of points.
func (*LeastSquaresFunction) AppendPoint ¶
func (lsf *LeastSquaresFunction) AppendPoint(x, y float64)
AppendPoint appends one point to the function.
func (*LeastSquaresFunction) AppendPoints ¶
func (lsf *LeastSquaresFunction) AppendPoints(points Points)
AppendPoints appends a set of points to the function.
func (*LeastSquaresFunction) Eval ¶
func (lsf *LeastSquaresFunction) Eval(x float64) float64
Eval evaluates the function for a given X value and returns the Y value.
func (*LeastSquaresFunction) EvalPoint ¶
func (lsf *LeastSquaresFunction) EvalPoint(x float64) *Point
EvalPoint evaluates the function for a given X value and returns the result as a point.
func (*LeastSquaresFunction) EvalPoints ¶
func (lsf *LeastSquaresFunction) EvalPoints(fromX, toX float64, count int) Points
EvalPoints evaluates the function for a range of X values and returns the result as a set of points.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point is just one point in a 2D coordinate system. The values for x or x are read-only.
func MiddlePoint ¶
MiddlePoint returns the middle point between two points.
func (Point) DistanceTo ¶
DistanceTo takes another point and calculates the geometric distance.
type Points ¶
type Points []*Point
Points is just a set of points.
func (Points) CubicSplineFunction ¶
func (ps Points) CubicSplineFunction() *CubicSplineFunction
CubicSplineFunction returns a cubic spline function based on the points.
func (Points) LeastSquaresFunction ¶
func (ps Points) LeastSquaresFunction() *LeastSquaresFunction
LeastSquaresFunction returns a least squares function based on the points.
func (Points) Less ¶
Less returns true if the point with index i is less then the one with index j. It first looks for X, then for Y.
func (Points) SearchNextIndex ¶
SearchNextIndex searches the next index fo a given X value.
func (Points) XDifference ¶
XDifference returns the difference between two X values of the set.
func (Points) YDifference ¶
YDifference returns the difference between two Y values of the set.
type PolynomialFunction ¶
type PolynomialFunction struct {
// contains filtered or unexported fields
}
PolynomialFunction is a polynomial function based on a number of coefficients.
func NewPolynomialFunction ¶
func NewPolynomialFunction(coefficients []float64) *PolynomialFunction
NewPolynomialFunction creates a new polynomial function.
func (PolynomialFunction) Differentiate ¶
func (pf PolynomialFunction) Differentiate() *PolynomialFunction
Differentiate differentiates the polynomial and returns the new polynomial.
func (PolynomialFunction) Eval ¶
func (pf PolynomialFunction) Eval(x float64) float64
Eval evaluates the function for a given X value and returns the Y value.
func (PolynomialFunction) EvalPoint ¶
func (pf PolynomialFunction) EvalPoint(x float64) *Point
EvalPoint evaluates the function for a given X value and returns the result as a point.
func (PolynomialFunction) EvalPoints ¶
func (pf PolynomialFunction) EvalPoints(fromX, toX float64, count int) Points
EvalPoints evaluates the function for a range of X values and returns the result as a set of points.
func (PolynomialFunction) String ¶
func (pf PolynomialFunction) String() string
String returns the string representation of the function as f(x) := 2.9x^3+x^2-3.3x+1.0.
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector represents a vector in a coordinate system. The values are read-only.
func AddVectors ¶
AddVectors returns a new vector as addition of two vectors.
func PointVector ¶
PointVector returns the vector between two poins.
func ScaleVector ¶
ScaleVectors multiplies a vector with a float and returns the new vector.
func SubVectors ¶
SubVectors returns a new vector as subtraction of two vectors.