Function gstreamer::functions::calculate_linear_regression[][src]

pub fn calculate_linear_regression(
    xy: &[(u64, u64)],
    temp: Option<&mut [(u64, u64)]>
) -> Option<(u64, u64, u64, u64, f64)>
This is supported on crate feature v1_12 only.
Expand description

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 None, it will be used as temporary space for the function, in which case the function works without any allocation at all. If temp is None, an allocation will take place. temp should have at least the same amount of memory allocated as xy, i.e. 2nsizeof(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.

xy

Pairs of (x,y) values

temp

Temporary scratch space used by the function

n

number of (x,y) pairs

Returns

true if the linear regression was successfully calculated

m_num

numerator of calculated slope

m_denom

denominator of calculated slope

b

Offset at Y-axis

xbase

Offset at X-axis

r_squared

R-squared