wcharczuk/go-chart · linear_regression_series.go
go logo
func (lrs LinearRegressionSeries) GetEndIndex() int {
	windowEnd := lrs.GetOffset() + lrs.GetLimit()
	innerSeriesLastIndex := lrs.InnerSeries.Len() - 1
	return util.Math.MinInt(windowEnd, innerSeriesLastIndex)
}
Similar code snippets
1.
wcharczuk/go-chart · polynomial_regression_series.go
Match rating: 75.05% · See similar code snippets
go logo
func (prs PolynomialRegressionSeries) GetEndIndex() int {
	windowEnd := prs.GetOffset() + prs.GetLimit()
	innerSeriesLastIndex := prs.InnerSeries.Len() - 1
	return util.Math.MinInt(windowEnd, innerSeriesLastIndex)
}
2.
wcharczuk/go-chart · linear_regression_series.go
Match rating: 74.75% · See similar code snippets
go logo
func (lrs LinearRegressionSeries) Len() int {
	return util.Math.MinInt(lrs.GetLimit(), lrs.InnerSeries.Len()-lrs.GetOffset())
}
3.
wcharczuk/go-chart · linear_regression_series.go
Match rating: 70.21% · See similar code snippets
go logo
func (lrs *LinearRegressionSeries) GetLastValues() (x, y float64) {
	if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
		return
	}
	if lrs.IsZero() {
		lrs.computeCoefficients()
	}
	endIndex := lrs.GetEndIndex()
	x, y = lrs.InnerSeries.GetValues(endIndex)
	y = (lrs.m * lrs.normalize(x)) + lrs.b
	return
}
4.
wcharczuk/go-chart · linear_regression_series.go
Match rating: 70.16% · See similar code snippets
go logo
func (lrs *LinearRegressionSeries) GetValues(index int) (x, y float64) {
	if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
		return
	}
	if lrs.IsZero() {
		lrs.computeCoefficients()
	}
	offset := lrs.GetOffset()
	effectiveIndex := util.Math.MinInt(index+offset, lrs.InnerSeries.Len())
	x, y = lrs.InnerSeries.GetValues(effectiveIndex)
	y = (lrs.m * lrs.normalize(x)) + lrs.b
	return
}
5.
wcharczuk/go-chart · linear_regression_series.go
Match rating: 68.37% · See similar code snippets
go logo
func (lrs LinearRegressionSeries) GetLimit() int {
	if lrs.Limit == 0 {
		return lrs.InnerSeries.Len()
	}
	return lrs.Limit
}
6.
wcharczuk/go-chart · linear_regression_series.go
Match rating: 66.21% · See similar code snippets
go logo
func (lrs *LinearRegressionSeries) GetFirstValues() (x, y float64) {
	if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
		return
	}
	if lrs.IsZero() {
		lrs.computeCoefficients()
	}
	x, y = lrs.InnerSeries.GetValues(0)
	y = (lrs.m * lrs.normalize(x)) + lrs.b
	return
}
7.
wcharczuk/go-chart · linear_regression_series.go
Match rating: 63.95% · See similar code snippets
go logo
func (lrs *LinearRegressionSeries) Validate() error {
	if lrs.InnerSeries == nil {
		return fmt.Errorf("linear regression series requires InnerSeries to be set")
	}
	return nil
}
8.
wcharczuk/go-chart · polynomial_regression_series.go
Match rating: 63.43% · See similar code snippets
go logo
func (prs *PolynomialRegressionSeries) Validate() error {
	if prs.InnerSeries == nil {
		return fmt.Errorf("linear regression series requires InnerSeries to be set")
	}

	endIndex := prs.GetEndIndex()
	if endIndex >= prs.InnerSeries.Len() {
		return fmt.Errorf("invalid window; inner series has length %d but end index is %d", prs.InnerSeries.Len(), endIndex)
	}

	return nil
}
9.
wcharczuk/go-chart · sma_series.go
Match rating: 62.14% · See similar code snippets
go logo
func (sma SMASeries) GetLastValues() (x, y float64) {
	if sma.InnerSeries == nil || sma.InnerSeries.Len() == 0 {
		return
	}
	seriesLen := sma.InnerSeries.Len()
	px, _ := sma.InnerSeries.GetValues(seriesLen - 1)
	x = px
	y = sma.getAverage(seriesLen - 1)
	return
}
10.
wcharczuk/go-chart · polynomial_regression_series.go
Match rating: 61.85% · See similar code snippets
go logo
func (prs PolynomialRegressionSeries) Len() int {
	return util.Math.MinInt(prs.GetLimit(), prs.InnerSeries.Len()-prs.GetOffset())
}