Utils.calculateLinearRegression

Calculates the linear regression of the values xy and places the result in m_num, m_denom, b and xbase, representing the function y(x) = m_num/m_denom * (x - xbase) + b that has the least-square distance from all points x and y.

r_squared will contain the remaining error.

If temp is not NULL, it will be used as temporary space for the function, in which case the function works without any allocation at all. If temp is NULL, an allocation will take place. temp should have at least the same amount of memory allocated as xy, i.e. 2*n*sizeof(GstClockTime).

> This function assumes (x,y) values with reasonable large differences > between them. It will not calculate the exact results if the differences > between neighbouring values are too small due to not being able to > represent sub-integer values during the calculations.

struct Utils
static
bool
calculateLinearRegression

Parameters

xy GstClockTime*

Pairs of (x,y) values

temp GstClockTime*

Temporary scratch space used by the function

n uint

number of (x,y) pairs

mNum GstClockTime

numerator of calculated slope

mDenom GstClockTime

denominator of calculated slope

b GstClockTime

Offset at Y-axis

xbase GstClockTime

Offset at X-axis

rSquared double

R-squared

Return Value

Type: bool

TRUE if the linear regression was successfully calculated

Meta

Since

1.12