summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2015-02-05 22:55:39 +1100
committerJan Schmidt <jan@centricular.com>2015-02-07 04:38:39 +1100
commit9d2b2768e35f59851b8f8d3dfac029a1469de34e (patch)
tree6cd7ace374171a7cb243226610e3f9e30654375b
parent08167e3234a3fb277bccb2de6370ff14e218616d (diff)
clock: Make linear regression x/y base start from maximum observation.
Project the results of the linear regression to the end of the regression range, so they're more directly comparable to results going forward
-rw-r--r--gst/gstclock-linreg.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gst/gstclock-linreg.c b/gst/gstclock-linreg.c
index 2164a9f0b..874917fef 100644
--- a/gst/gstclock-linreg.c
+++ b/gst/gstclock-linreg.c
@@ -217,8 +217,11 @@ _priv_gst_do_linear_regression (GstClockTime * times, guint n,
*m_num = sxy;
*m_denom = sxx;
- *xbase = xmin;
- *b = (ybar + ymin) - gst_util_uint64_scale (xbar, *m_num, *m_denom);
+ *b = (ymin + ybar) - gst_util_uint64_scale (xbar, *m_num, *m_denom);
+ /* Report base starting from the most recent observation */
+ *xbase = xmax;
+ *b += gst_util_uint64_scale (xmax - xmin, *m_num, *m_denom);
+
*r_squared = ((double) sxy * (double) sxy) / ((double) sxx * (double) syy);
#ifdef DEBUGGING_ENABLED