csv-analysis: github.com/DavidGamba/csv-analysis/regression

## package regression

`import "github.com/DavidGamba/csv-analysis/regression"`

Package regression provides linear transformation functions.

Package regression provides linear transformation functions.

Package regression provides linear transformation functions.

### func NewPlot¶Uses

`func NewPlot(ps PlotSettings) (*plot.Plot, error)`

NewPlot -

### func PlotRegression¶Uses

`func PlotRegression(x []float64, ys [][]float64, f func(float64) float64, r2, sDev float64, ps PlotSettings) error`

PlotRegression -

### func PlotTimeData¶Uses

`func PlotTimeData(x []float64, ys [][]float64, ps PlotSettings) error`

PlotTimeData -

### func PolynomialRegression¶Uses

`func PolynomialRegression(m int, x, y []float64) (*mat.Dense, error)`

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ᵢ
```

### type BOverX¶Uses

`type BOverX struct{}`

BOverX - Provides the transformation functions that satisfy:

```y = a + b / (1 + x)
```

to:

```y = a + b * 1 / (1 + x)
```

#### func (*BOverX) FRestoreA¶Uses

`func (*BOverX) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*BOverX) FRestoreB¶Uses

`func (*BOverX) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*BOverX) FTransformX¶Uses

`func (*BOverX) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*BOverX) FTransformY¶Uses

`func (*BOverX) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*BOverX) FX¶Uses

`func (*BOverX) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = 1 / (a + bx)
```

#### func (*BOverX) FY¶Uses

`func (*BOverX) FY(a, b, y float64) (x float64)`

FY - Solve the equation for y, used for interpolation

```x = (1/((y -a ) / b)) - 1
```

#### func (*BOverX) Name¶Uses

`func (*BOverX) Name() string`

Name - Name

#### func (*BOverX) TLabel¶Uses

`func (*BOverX) TLabel() string`

TLabel - Top label

#### func (*BOverX) TextEquation¶Uses

`func (*BOverX) TextEquation() string`

TextEquation - ASCII equation

#### func (*BOverX) TextTransformedEquation¶Uses

`func (*BOverX) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*BOverX) XLabel¶Uses

`func (*BOverX) XLabel() string`

XLabel - X label

#### func (*BOverX) YLabel¶Uses

`func (*BOverX) YLabel() string`

YLabel - Y label

### type Exponential¶Uses

`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¶Uses

`func (*Exponential) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*Exponential) FRestoreB¶Uses

`func (*Exponential) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*Exponential) FTransformX¶Uses

`func (*Exponential) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*Exponential) FTransformY¶Uses

`func (*Exponential) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*Exponential) FX¶Uses

`func (*Exponential) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = aB^x
```

#### func (*Exponential) FY¶Uses

`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) Name¶Uses

`func (*Exponential) Name() string`

Name - Name

#### func (*Exponential) TLabel¶Uses

`func (*Exponential) TLabel() string`

TLabel - Top label

#### func (*Exponential) TextEquation¶Uses

`func (*Exponential) TextEquation() string`

TextEquation - ASCII equation

#### func (*Exponential) TextTransformedEquation¶Uses

`func (*Exponential) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*Exponential) XLabel¶Uses

`func (*Exponential) XLabel() string`

XLabel - X label

#### func (*Exponential) YLabel¶Uses

`func (*Exponential) YLabel() string`

YLabel - Y label

### type Interpolation¶Uses

```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¶Uses

```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¶Uses

`type LnPower struct{}`

LnPower - Provides the transformation functions that satisfy:

```y = ln(ax^b)
```

to:

```y = ln a + b * ln x
```

#### func (*LnPower) FRestoreA¶Uses

`func (*LnPower) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*LnPower) FRestoreB¶Uses

`func (*LnPower) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*LnPower) FTransformX¶Uses

`func (*LnPower) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*LnPower) FTransformY¶Uses

`func (*LnPower) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*LnPower) FX¶Uses

`func (*LnPower) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = ln a + b ln x
```

#### func (*LnPower) FY¶Uses

`func (*LnPower) FY(a, b, y float64) (x float64)`

FY - Solve the equation for y, used for interpolation

```x = ((y - b)/ln a)^e
```

#### func (*LnPower) Name¶Uses

`func (*LnPower) Name() string`

Name - Name

#### func (*LnPower) TLabel¶Uses

`func (*LnPower) TLabel() string`

TLabel - Top label

#### func (*LnPower) TextEquation¶Uses

`func (*LnPower) TextEquation() string`

TextEquation - ASCII equation

#### func (*LnPower) TextTransformedEquation¶Uses

`func (*LnPower) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*LnPower) XLabel¶Uses

`func (*LnPower) XLabel() string`

XLabel - X label

#### func (*LnPower) YLabel¶Uses

`func (*LnPower) YLabel() string`

YLabel - Y label

### type None¶Uses

`type None struct{}`

None - No transformation

#### func (*None) FRestoreA¶Uses

`func (*None) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*None) FRestoreB¶Uses

`func (*None) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*None) FTransformX¶Uses

`func (*None) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*None) FTransformY¶Uses

`func (*None) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*None) FX¶Uses

`func (*None) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = a + bx
```

#### func (*None) FY¶Uses

`func (*None) FY(a, b, y float64) (x float64)`

FY - Solve the equation for y, used for interpolation

```x = (y - a)/b
```

#### func (*None) Name¶Uses

`func (*None) Name() string`

Name - Name

#### func (*None) TLabel¶Uses

`func (*None) TLabel() string`

TLabel - Top label

#### func (*None) TextEquation¶Uses

`func (*None) TextEquation() string`

TextEquation - ASCII equation

#### func (*None) TextTransformedEquation¶Uses

`func (*None) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*None) XLabel¶Uses

`func (*None) XLabel() string`

XLabel - X label

#### func (*None) YLabel¶Uses

`func (*None) YLabel() string`

YLabel - Y label

### type OneOverX¶Uses

`type OneOverX struct{}`

OneOverX - Provides the transformation functions that satisfy:

```y = 1 / (a + bx)
```

to:

```1/y = a + bx
```

#### func (*OneOverX) FRestoreA¶Uses

`func (*OneOverX) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*OneOverX) FRestoreB¶Uses

`func (*OneOverX) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*OneOverX) FTransformX¶Uses

`func (*OneOverX) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*OneOverX) FTransformY¶Uses

`func (*OneOverX) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*OneOverX) FX¶Uses

`func (*OneOverX) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = 1 / (a + bx)
```

#### func (*OneOverX) FY¶Uses

`func (*OneOverX) FY(a, b, y float64) (x float64)`

FY - Solve the equation for y, used for interpolation

```x = (1/y - a) / b
```

#### func (*OneOverX) Name¶Uses

`func (*OneOverX) Name() string`

Name - Name

#### func (*OneOverX) TLabel¶Uses

`func (*OneOverX) TLabel() string`

TLabel - Top label

#### func (*OneOverX) TextEquation¶Uses

`func (*OneOverX) TextEquation() string`

TextEquation - ASCII equation

#### func (*OneOverX) TextTransformedEquation¶Uses

`func (*OneOverX) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*OneOverX) XLabel¶Uses

`func (*OneOverX) XLabel() string`

XLabel - X label

#### func (*OneOverX) YLabel¶Uses

`func (*OneOverX) YLabel() string`

YLabel - Y label

### type OneOverX2¶Uses

`type OneOverX2 struct{}`

OneOverX2 - Provides the transformation functions that satisfy:

```y = 1 / (a + bx)^2
```

to:

```1/sqrt(y) = a + bx
```

#### func (*OneOverX2) FRestoreA¶Uses

`func (*OneOverX2) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*OneOverX2) FRestoreB¶Uses

`func (*OneOverX2) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*OneOverX2) FTransformX¶Uses

`func (*OneOverX2) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*OneOverX2) FTransformY¶Uses

`func (*OneOverX2) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*OneOverX2) FX¶Uses

`func (*OneOverX2) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = 1 / (a + bx)^2
```

#### func (*OneOverX2) FY¶Uses

`func (*OneOverX2) FY(a, b, y float64) (x float64)`

FY - Solve the equation for y, used for interpolation

```x = (1/sqrt(y) - a)/b
```

#### func (*OneOverX2) Name¶Uses

`func (*OneOverX2) Name() string`

Name - Name

#### func (*OneOverX2) TLabel¶Uses

`func (*OneOverX2) TLabel() string`

TLabel - Top label

#### func (*OneOverX2) TextEquation¶Uses

`func (*OneOverX2) TextEquation() string`

TextEquation - ASCII equation

#### func (*OneOverX2) TextTransformedEquation¶Uses

`func (*OneOverX2) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*OneOverX2) XLabel¶Uses

`func (*OneOverX2) XLabel() string`

XLabel - X label

#### func (*OneOverX2) YLabel¶Uses

`func (*OneOverX2) YLabel() string`

YLabel - Y label

### type PlotSettings¶Uses

```type PlotSettings struct {
Title     string
XLabel    string
YLabel    string
DataLabel string
Bold      bool
}```

PlotSettings -

### type Plotter¶Uses

```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¶Uses

```type PolynomialSolution struct {
X, Y   []float64 // Original data slices.
Degree int
A      *mat.Dense // Solution
R2     float64
SDev   float64
}```

PolynomialSolution - Polynomial solution.

#### func SolvePolynomial¶Uses

`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¶Uses

`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) Plot¶Uses

`func (s PolynomialSolution) Plot() error`

Plot -

#### func (PolynomialSolution) PolynomialFunction¶Uses

`func (s PolynomialSolution) PolynomialFunction() func(x float64) float64`

PolynomialFunction - Returns a linear function based on the provided A matrix.

### type Power¶Uses

`type Power struct{}`

Power - Provides the transformation functions that satisfy:

```y = ax^b
```

to:

```log y = log a + b * log x
```

#### func (*Power) FRestoreA¶Uses

`func (*Power) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*Power) FRestoreB¶Uses

`func (*Power) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*Power) FTransformX¶Uses

`func (*Power) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*Power) FTransformY¶Uses

`func (*Power) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*Power) FX¶Uses

`func (*Power) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = ax^b
```

#### func (*Power) FY¶Uses

`func (*Power) FY(a, b, y float64) (x float64)`

FY - Solve the equation for y, used for interpolation

```x = sqrt(y/a,b)
```

#### func (*Power) Name¶Uses

`func (*Power) Name() string`

Name - Name

#### func (*Power) TLabel¶Uses

`func (*Power) TLabel() string`

TLabel - Top label

#### func (*Power) TextEquation¶Uses

`func (*Power) TextEquation() string`

TextEquation - Text equation

#### func (*Power) TextTransformedEquation¶Uses

`func (*Power) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*Power) XLabel¶Uses

`func (*Power) XLabel() string`

XLabel - X label

#### func (*Power) YLabel¶Uses

`func (*Power) YLabel() string`

YLabel - Y label

### type Solution¶Uses

```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¶Uses

`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¶Uses

`func (s Solution) LinearFunction() func(x float64) float64`

LinearFunction - Returns a linear function based on the transformed At and Bt values.

#### func (Solution) Plot¶Uses

`func (s Solution) Plot(p Plotter) error`

Plot -

#### func (Solution) PlotLinearTransformation¶Uses

`func (s Solution) PlotLinearTransformation(p Plotter) error`

PlotLinearTransformation -

#### func (Solution) RegressionFunction¶Uses

`func (s Solution) RegressionFunction() func(x float64) float64`

RegressionFunction -

### type Sqrt¶Uses

`type Sqrt struct{}`

Sqrt - Provides the transformation functions that satisfy:

```y = a + b * sqrt(x)
```

to:

```y = a + b * sqrt(x)
```

#### func (*Sqrt) FRestoreA¶Uses

`func (*Sqrt) FRestoreA(at float64) (a float64)`

FRestoreA - function to restore A

#### func (*Sqrt) FRestoreB¶Uses

`func (*Sqrt) FRestoreB(bt float64) (b float64)`

FRestoreB - function to restore B

#### func (*Sqrt) FTransformX¶Uses

`func (*Sqrt) FTransformX(x float64) (xt float64)`

FTransformX - function to transform X

#### func (*Sqrt) FTransformY¶Uses

`func (*Sqrt) FTransformY(y float64) (yt float64)`

FTransformY - function to transform Y

#### func (*Sqrt) FX¶Uses

`func (*Sqrt) FX(a, b, x float64) (y float64)`

FX - Function to calculate normal y values

```y = a + b * sqrt(x)
```

#### func (*Sqrt) FY¶Uses

`func (*Sqrt) FY(a, b, y float64) (x float64)`

FY - Solve the equation for y, used for interpolation

```x = ((y - a)/b)^2
```

#### func (*Sqrt) Name¶Uses

`func (*Sqrt) Name() string`

Name - Name

#### func (*Sqrt) TLabel¶Uses

`func (*Sqrt) TLabel() string`

TLabel - Top label

#### func (*Sqrt) TextEquation¶Uses

`func (*Sqrt) TextEquation() string`

TextEquation - ASCII equation

#### func (*Sqrt) TextTransformedEquation¶Uses

`func (*Sqrt) TextTransformedEquation() string`

TextTransformedEquation - Text equation

#### func (*Sqrt) XLabel¶Uses

`func (*Sqrt) XLabel() string`

XLabel - X label

#### func (*Sqrt) YLabel¶Uses

`func (*Sqrt) YLabel() string`

YLabel - Y label

### type YDataLabel¶Uses

```type YDataLabel struct {
Data  plotter.XYs
Label string
}```

YDataLabel -

Package regression imports 10 packages (graph) and is imported by 1 packages. Updated 2018-10-03. Refresh now. Tools for package owners.