fabricator

package module
v0.0.0-...-abec400 Latest Latest
Warning

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

Go to latest
Published: May 17, 2016 License: MIT Imports: 3 Imported by: 0

README

Fabricator

Go Report Card GoDoc

A Go (golang) package for fabricating any two dimensional data which have a linear relationship. Can be used to create new data from an existing set, or generate multiple trials which roughly average out to the original data.

Examples

See /examples for example usage.

License

Fabricator is licensed under the MIT license which can be found here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fabricator

type Fabricator struct {
	// contains filtered or unexported fields
}

Fabricator represents the fabricator generated from a set of results.

func (*Fabricator) Apply

func (f *Fabricator) Apply(useY bool, res ResultSet)

Apply applies the Fabricator on a given result set. Call this method multiple times to generate multiple trials. Set useY to true if you want to fill values of X using Y, instead of filling values of Y using X.

func (*Fabricator) ErrorRange

func (f *Fabricator) ErrorRange() float64

ErrorRange returns the error range of Y values on the Fabricator.

func (*Fabricator) Gradient

func (f *Fabricator) Gradient() float64

Gradient returns gradient of the Fabricator.

func (*Fabricator) GradientError

func (f *Fabricator) GradientError(rangeVal float64)

GradientError sets the slope of the Fabricator model to a random value in the given range from the original gradient.

func (*Fabricator) SetErrorRange

func (f *Fabricator) SetErrorRange(rangeVal float64)

SetErrorRange sets the range of trials returned by the Fabricator using the given range.

func (*Fabricator) YIntercept

func (f *Fabricator) YIntercept() float64

YIntercept returns the y-intercept of the Fabricator.

func (*Fabricator) YInterceptError

func (f *Fabricator) YInterceptError(rangeVal float64)

YInterceptError sets the y-intercept of the Fabricator model to a random value in the given range from the original y-intercept.

type Result

type Result struct {
	X float64
	Y float64
}

Result represents a single result, i.e. a data point.

type ResultSet

type ResultSet []Result

ResultSet represents a set of Result that is sorted in ascending order of X.

func NewResultSet

func NewResultSet() ResultSet

NewResultSet returns a new ResultSet.

func (ResultSet) Add

func (r ResultSet) Add(res Result) ResultSet

Add adds a Result to a ResultSet in ascending order of X.

func (ResultSet) Copy

func (r ResultSet) Copy() ResultSet

Copy returns a copy of the ResultSet.

func (ResultSet) Fabricate

func (r ResultSet) Fabricate() *Fabricator

Fabricate returns a perfect (i.e. no errors) Fabricator based on the ResultSet.

func (ResultSet) LinearRegression

func (r ResultSet) LinearRegression() (float64, float64)

LinearRegression performs linear regression on the ResultSet using least squares, and returns the gradient and y-intercept.

func (ResultSet) Sort

func (r ResultSet) Sort()

Sort sorts the ResultSet in ascending order of X.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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