Help us shape the future of Go! Take the 2026 Go Developer Survey

go-online-linear-regression

command module
v0.0.0-...-2ea9bbc Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: MIT Imports: 4 Imported by: 0

README

#go-online-linear-regression Build Status GoDoc

Library to calculate online linear regression.

##Example

package main

import (
	"fmt"
	"github.com/gaillard/go-online-linear-regression/v1"
)

func main() {
	//xDelta argument of 7 will cause the point added with r.Add(1.5, 4.4) to be removed before last fmt.Printf()
	r := regression.New(7)

	r.Add(1.5, 4.4)
	r.Add(2.9, 1.56)

	slope, intercept, stdError := r.CalculateWithStdError()
	fmt.Printf("slope %f\n", slope)
	fmt.Printf("intercept %f\n", intercept)
	fmt.Printf("standard error %f\n", stdError)

	r.Add(7.2, 10.5)
	r.Add(9, 7.6)

	slope, intercept, stdError = r.CalculateWithStdError()
	fmt.Printf("slope %f\n", slope)
	fmt.Printf("intercept %f\n", intercept)
	fmt.Printf("standard error %f\n", stdError)
}

Outputs

slope -2.028571
intercept 7.442857
standard error NaN
slope 1.188768
intercept -1.015158
standard error 3.720348

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package regression provides online linear regression calculation.
Package regression provides online linear regression calculation.

Jump to

Keyboard shortcuts

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