Adding upstream version 2.1.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c8c64afc61
commit
41a2f19f12
220 changed files with 19814 additions and 0 deletions
42
linear_coefficient_provider.go
Normal file
42
linear_coefficient_provider.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package chart
|
||||
|
||||
// LinearCoefficientProvider is a type that returns linear cofficients.
|
||||
type LinearCoefficientProvider interface {
|
||||
Coefficients() (m, b, stdev, avg float64)
|
||||
}
|
||||
|
||||
// LinearCoefficients returns a fixed linear coefficient pair.
|
||||
func LinearCoefficients(m, b float64) LinearCoefficientSet {
|
||||
return LinearCoefficientSet{
|
||||
M: m,
|
||||
B: b,
|
||||
}
|
||||
}
|
||||
|
||||
// NormalizedLinearCoefficients returns a fixed linear coefficient pair.
|
||||
func NormalizedLinearCoefficients(m, b, stdev, avg float64) LinearCoefficientSet {
|
||||
return LinearCoefficientSet{
|
||||
M: m,
|
||||
B: b,
|
||||
StdDev: stdev,
|
||||
Avg: avg,
|
||||
}
|
||||
}
|
||||
|
||||
// LinearCoefficientSet is the m and b values for the linear equation in the form:
|
||||
// y = (m*x) + b
|
||||
type LinearCoefficientSet struct {
|
||||
M float64
|
||||
B float64
|
||||
StdDev float64
|
||||
Avg float64
|
||||
}
|
||||
|
||||
// Coefficients returns the coefficients.
|
||||
func (lcs LinearCoefficientSet) Coefficients() (m, b, stdev, avg float64) {
|
||||
m = lcs.M
|
||||
b = lcs.B
|
||||
stdev = lcs.StdDev
|
||||
avg = lcs.Avg
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue