linear

package
v0.0.0-...-d1d5330 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cdf

func Cdf(x []float64) (sortedX, y []float64)

Return the x array sorted and the y array containing empirical CDF value foreach x's value. len(x)=len(y)

Example
sortedX := []float64{2.5, 2.98, 3, 3, 3.14, 5, 10}
x, y := Cdf(sortedX)
for i := range x {
	fmt.Println("x:", x[i], "y:", y[i])
}
Output:

x: 2.5 y: 0.14285714285714285
x: 2.98 y: 0.2857142857142857
x: 3 y: 0.5714285714285714
x: 3 y: 0.5714285714285714
x: 3.14 y: 0.7142857142857143
x: 5 y: 0.8571428571428571
x: 10 y: 1

Types

type RegressionModel

type RegressionModel struct {
	Intercept, Slope float64
}

Model is a LinearRegression model

func Fit

func Fit(x, y []float64) *RegressionModel

Fit return a Model structure fitted with alpha and beta of a LinearRegression applied on x. Y is the CDF value

func (*RegressionModel) Predict

func (m *RegressionModel) Predict(x float64) (predCDF float64)

Predict the CDF result of a given x

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL