Debian Codegraph @

linear_coefficient_provider.go

raw symbols SCIP
1 package chart
2
3 // LinearCoefficientProvider is a type that returns linear cofficients.
4 type LinearCoefficientProvider interface {
5 Coefficients() (m, b, stdev, avg float64)
6 }
7
8 // LinearCoefficients returns a fixed linear coefficient pair.
9 func LinearCoefficients(m, b float64) LinearCoefficientSet {
10 return LinearCoefficientSet{
11 M: m,
12 B: b,
13 }
14 }
15
16 // NormalizedLinearCoefficients returns a fixed linear coefficient pair.
17 func NormalizedLinearCoefficients(m, b, stdev, avg float64) LinearCoefficientSet {
18 return LinearCoefficientSet{
19 M: m,
20 B: b,
21 StdDev: stdev,
22 Avg: avg,
23 }
24 }
25
26 // LinearCoefficientSet is the m and b values for the linear equation in the form:
27 // y = (m*x) + b
28 type LinearCoefficientSet struct {
29 M float64
30 B float64
31 StdDev float64
32 Avg float64
33 }
34
35 // Coefficients returns the coefficients.
36 func (lcs LinearCoefficientSet) Coefficients() (m, b, stdev, avg float64) {
37 m = lcs.M
38 b = lcs.B
39 stdev = lcs.StdDev
40 avg = lcs.Avg
41 return
42 }