Documentation ¶
Overview ¶
Package regression provides linear transformation functions.
Package regression provides linear transformation functions.
Package regression provides linear transformation functions.
Index ¶
- func NewPlot(ps PlotSettings) (*plot.Plot, error)
- func PlotRegression(x []float64, ys [][]float64, f func(float64) float64, r2, sDev float64, ...) error
- func PlotTimeData(x []float64, ys [][]float64, ps PlotSettings) error
- func PolynomialRegression(m int, x, y []float64) (*mat.Dense, error)
- type BOverX
- func (*BOverX) FRestoreA(at float64) (a float64)
- func (*BOverX) FRestoreB(bt float64) (b float64)
- func (*BOverX) FTransformX(x float64) (xt float64)
- func (*BOverX) FTransformY(y float64) (yt float64)
- func (*BOverX) FX(a, b, x float64) (y float64)
- func (*BOverX) FY(a, b, y float64) (x float64)
- func (*BOverX) Name() string
- func (*BOverX) TLabel() string
- func (*BOverX) TextEquation() string
- func (*BOverX) TextTransformedEquation() string
- func (*BOverX) XLabel() string
- func (*BOverX) YLabel() string
- type Exponential
- func (*Exponential) FRestoreA(at float64) (a float64)
- func (*Exponential) FRestoreB(bt float64) (b float64)
- func (*Exponential) FTransformX(x float64) (xt float64)
- func (*Exponential) FTransformY(y float64) (yt float64)
- func (*Exponential) FX(a, b, x float64) (y float64)
- func (*Exponential) FY(a, b, y float64) (x float64)
- func (*Exponential) Name() string
- func (*Exponential) TLabel() string
- func (*Exponential) TextEquation() string
- func (*Exponential) TextTransformedEquation() string
- func (*Exponential) XLabel() string
- func (*Exponential) YLabel() string
- type Interpolation
- type LinearTransformation
- type LnPower
- func (*LnPower) FRestoreA(at float64) (a float64)
- func (*LnPower) FRestoreB(bt float64) (b float64)
- func (*LnPower) FTransformX(x float64) (xt float64)
- func (*LnPower) FTransformY(y float64) (yt float64)
- func (*LnPower) FX(a, b, x float64) (y float64)
- func (*LnPower) FY(a, b, y float64) (x float64)
- func (*LnPower) Name() string
- func (*LnPower) TLabel() string
- func (*LnPower) TextEquation() string
- func (*LnPower) TextTransformedEquation() string
- func (*LnPower) XLabel() string
- func (*LnPower) YLabel() string
- type None
- func (*None) FRestoreA(at float64) (a float64)
- func (*None) FRestoreB(bt float64) (b float64)
- func (*None) FTransformX(x float64) (xt float64)
- func (*None) FTransformY(y float64) (yt float64)
- func (*None) FX(a, b, x float64) (y float64)
- func (*None) FY(a, b, y float64) (x float64)
- func (*None) Name() string
- func (*None) TLabel() string
- func (*None) TextEquation() string
- func (*None) TextTransformedEquation() string
- func (*None) XLabel() string
- func (*None) YLabel() string
- type OneOverX
- func (*OneOverX) FRestoreA(at float64) (a float64)
- func (*OneOverX) FRestoreB(bt float64) (b float64)
- func (*OneOverX) FTransformX(x float64) (xt float64)
- func (*OneOverX) FTransformY(y float64) (yt float64)
- func (*OneOverX) FX(a, b, x float64) (y float64)
- func (*OneOverX) FY(a, b, y float64) (x float64)
- func (*OneOverX) Name() string
- func (*OneOverX) TLabel() string
- func (*OneOverX) TextEquation() string
- func (*OneOverX) TextTransformedEquation() string
- func (*OneOverX) XLabel() string
- func (*OneOverX) YLabel() string
- type OneOverX2
- func (*OneOverX2) FRestoreA(at float64) (a float64)
- func (*OneOverX2) FRestoreB(bt float64) (b float64)
- func (*OneOverX2) FTransformX(x float64) (xt float64)
- func (*OneOverX2) FTransformY(y float64) (yt float64)
- func (*OneOverX2) FX(a, b, x float64) (y float64)
- func (*OneOverX2) FY(a, b, y float64) (x float64)
- func (*OneOverX2) Name() string
- func (*OneOverX2) TLabel() string
- func (*OneOverX2) TextEquation() string
- func (*OneOverX2) TextTransformedEquation() string
- func (*OneOverX2) XLabel() string
- func (*OneOverX2) YLabel() string
- type PlotSettings
- type Plotter
- type PolynomialSolution
- type Power
- func (*Power) FRestoreA(at float64) (a float64)
- func (*Power) FRestoreB(bt float64) (b float64)
- func (*Power) FTransformX(x float64) (xt float64)
- func (*Power) FTransformY(y float64) (yt float64)
- func (*Power) FX(a, b, x float64) (y float64)
- func (*Power) FY(a, b, y float64) (x float64)
- func (*Power) Name() string
- func (*Power) TLabel() string
- func (*Power) TextEquation() string
- func (*Power) TextTransformedEquation() string
- func (*Power) XLabel() string
- func (*Power) YLabel() string
- type Solution
- type Sqrt
- func (*Sqrt) FRestoreA(at float64) (a float64)
- func (*Sqrt) FRestoreB(bt float64) (b float64)
- func (*Sqrt) FTransformX(x float64) (xt float64)
- func (*Sqrt) FTransformY(y float64) (yt float64)
- func (*Sqrt) FX(a, b, x float64) (y float64)
- func (*Sqrt) FY(a, b, y float64) (x float64)
- func (*Sqrt) Name() string
- func (*Sqrt) TLabel() string
- func (*Sqrt) TextEquation() string
- func (*Sqrt) TextTransformedEquation() string
- func (*Sqrt) XLabel() string
- func (*Sqrt) YLabel() string
- type YDataLabel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PlotRegression ¶
func PlotRegression(x []float64, ys [][]float64, f func(float64) float64, r2, sDev float64, ps PlotSettings) error
PlotRegression -
func PlotTimeData ¶
func PlotTimeData(x []float64, ys [][]float64, ps PlotSettings) error
PlotTimeData -
func PolynomialRegression ¶
PolynomialRegression - Least Squares Polynomial Regression Returns A and B matrix based on the given polynomial degree. m: polynomial degree n: number of points When m = 2:
A = B (n)a₀ + (∑xᵢ)a₁ + (∑xᵢ²)a₂ = ∑yᵢ (∑xᵢ)a₀ + (∑xᵢ²)a₁ + (∑xᵢ³)a₂ = ∑xᵢyᵢ (∑xᵢ²)a₀ + (∑xᵢ³)a₁ + (∑xᵢ⁴)a₂ = ∑xᵢ²yᵢ
Types ¶
type BOverX ¶
type BOverX struct{}
BOverX - Provides the transformation functions that satisfy:
y = a + b / (1 + x)
to:
y = a + b * 1 / (1 + x)
func (*BOverX) FTransformX ¶
FTransformX - function to transform X
func (*BOverX) FTransformY ¶
FTransformY - function to transform Y
func (*BOverX) TextTransformedEquation ¶
TextTransformedEquation - Text equation
type Exponential ¶
type Exponential struct{}
Exponential - Provides the transformation functions that satisfy:
y = ae^(bx) = aB^x
to:
ln y = ln a + bx = ln a + ln B * x
func (*Exponential) FRestoreA ¶
func (*Exponential) FRestoreA(at float64) (a float64)
FRestoreA - function to restore A
func (*Exponential) FRestoreB ¶
func (*Exponential) FRestoreB(bt float64) (b float64)
FRestoreB - function to restore B
func (*Exponential) FTransformX ¶
func (*Exponential) FTransformX(x float64) (xt float64)
FTransformX - function to transform X
func (*Exponential) FTransformY ¶
func (*Exponential) FTransformY(y float64) (yt float64)
FTransformY - function to transform Y
func (*Exponential) FX ¶
func (*Exponential) FX(a, b, x float64) (y float64)
FX - Function to calculate normal y values
y = aB^x
func (*Exponential) FY ¶
func (*Exponential) FY(a, b, y float64) (x float64)
FY - Solve the equation for y, used for interpolation
x = ln(y/a)/ln(b)
func (*Exponential) TextEquation ¶
func (*Exponential) TextEquation() string
TextEquation - ASCII equation
func (*Exponential) TextTransformedEquation ¶
func (*Exponential) TextTransformedEquation() string
TextTransformedEquation - Text equation
type Interpolation ¶
type Interpolation interface { FY(a, b, y float64) float64 // fy(y) solve the equation for y, used for interpolation. FX(a, b, x float64) float64 // fx(x) }
Interpolation - Allows to get an X or Y point based on y or x.
type LinearTransformation ¶
type LinearTransformation interface { Name() string FX(a, b, x float64) float64 // fx(x) FTransformX(x float64) float64 // function to transform X FTransformY(y float64) float64 // function to transform Y FRestoreA(at float64) float64 // function to restore A FRestoreB(bt float64) float64 // function to restore B }
LinearTransformation -
type LnPower ¶
type LnPower struct{}
LnPower - Provides the transformation functions that satisfy:
y = ln(ax^b)
to:
y = ln a + b * ln x
func (*LnPower) FTransformX ¶
FTransformX - function to transform X
func (*LnPower) FTransformY ¶
FTransformY - function to transform Y
func (*LnPower) TextTransformedEquation ¶
TextTransformedEquation - Text equation
type None ¶
type None struct{}
None - No transformation
func (*None) FTransformX ¶
FTransformX - function to transform X
func (*None) FTransformY ¶
FTransformY - function to transform Y
func (*None) TextTransformedEquation ¶
TextTransformedEquation - Text equation
type OneOverX ¶
type OneOverX struct{}
OneOverX - Provides the transformation functions that satisfy:
y = 1 / (a + bx)
to:
1/y = a + bx
func (*OneOverX) FTransformX ¶
FTransformX - function to transform X
func (*OneOverX) FTransformY ¶
FTransformY - function to transform Y
func (*OneOverX) TextEquation ¶
TextEquation - ASCII equation
func (*OneOverX) TextTransformedEquation ¶
TextTransformedEquation - Text equation
type OneOverX2 ¶
type OneOverX2 struct{}
OneOverX2 - Provides the transformation functions that satisfy:
y = 1 / (a + bx)^2
to:
1/sqrt(y) = a + bx
func (*OneOverX2) FTransformX ¶
FTransformX - function to transform X
func (*OneOverX2) FTransformY ¶
FTransformY - function to transform Y
func (*OneOverX2) TextEquation ¶
TextEquation - ASCII equation
func (*OneOverX2) TextTransformedEquation ¶
TextTransformedEquation - Text equation
type PlotSettings ¶
PlotSettings -
type Plotter ¶
type Plotter interface { Name() string TextEquation() string TextTransformedEquation() string TLabel() string // Top label XLabel() string // X label YLabel() string // Y label FX(a, b, x float64) float64 // fx(x) }
Plotter -
type PolynomialSolution ¶
type PolynomialSolution struct {
X, Y []float64 // Original data slices.
Degree int
A *mat.Dense // Solution
R2 float64
SDev float64
}
PolynomialSolution - Polynomial solution.
func SolvePolynomial ¶
func SolvePolynomial(xo, yo []float64, degree int) (PolynomialSolution, error)
SolvePolynomial - Given a pointer to X and Y []float64 data and a linear transformation function, it will return the solution.
func SolvePolynomialReverseMatrix ¶
func SolvePolynomialReverseMatrix(xo, yo []float64, degree int) (PolynomialSolution, error)
SolvePolynomialReverseMatrix - Given a pointer to X and Y []float64 data and a linear transformation function, it will return the solution using the Reverse Matrix.
func (PolynomialSolution) PolynomialFunction ¶
func (s PolynomialSolution) PolynomialFunction() func(x float64) float64
PolynomialFunction - Returns a linear function based on the provided A matrix.
type Power ¶
type Power struct{}
Power - Provides the transformation functions that satisfy:
y = ax^b
to:
log y = log a + b * log x
func (*Power) FTransformX ¶
FTransformX - function to transform X
func (*Power) FTransformY ¶
FTransformY - function to transform Y
func (*Power) TextTransformedEquation ¶
TextTransformedEquation - Text equation
type Solution ¶
type Solution struct {
X, Y []float64 // original data slices.
Xt, Yt []float64 // transformed data slices
At, Bt float64 // solution to the transformed linear equation
A, B float64 // solution to the linear equation
LT LinearTransformation
R2t float64
R2 float64
SDevt float64
SDev float64
}
Solution - Linear Transformation Solution.
func SolveTransformation ¶
func SolveTransformation(xo, yo []float64, lt LinearTransformation) (Solution, error)
SolveTransformation - Given a pointer to X and Y []float64 data and a linear transformation function, it will return the solution.
func (Solution) LinearFunction ¶
LinearFunction - Returns a linear function based on the transformed At and Bt values.
func (Solution) PlotLinearTransformation ¶
PlotLinearTransformation -
func (Solution) RegressionFunction ¶
RegressionFunction -
type Sqrt ¶
type Sqrt struct{}
Sqrt - Provides the transformation functions that satisfy:
y = a + b * sqrt(x)
to:
y = a + b * sqrt(x)
func (*Sqrt) FTransformX ¶
FTransformX - function to transform X
func (*Sqrt) FTransformY ¶
FTransformY - function to transform Y
func (*Sqrt) TextTransformedEquation ¶
TextTransformedEquation - Text equation