From 4f367471aed2ac8947a6f9df19be3a0294a7d4bb Mon Sep 17 00:00:00 2001 From: Davis King Date: Fri, 1 Apr 2016 11:38:16 -0400 Subject: [PATCH] Added a member function to get the line intercept from running_gradient. --- dlib/statistics/running_gradient.h | 12 ++++++++++++ dlib/statistics/running_gradient_abstract.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/dlib/statistics/running_gradient.h b/dlib/statistics/running_gradient.h index 368ce6b2b..1d40ac313 100644 --- a/dlib/statistics/running_gradient.h +++ b/dlib/statistics/running_gradient.h @@ -72,6 +72,18 @@ namespace dlib return w(0); } + double intercept ( + ) const + { + // make sure requires clause is not broken + DLIB_ASSERT(current_n() > 0, + "\t double running_gradient::intercept()" + << "\n\t You must add more values into this object before calling this function." + << "\n\t this: " << this + ); + + return w(1); + } double standard_error ( ) const { diff --git a/dlib/statistics/running_gradient_abstract.h b/dlib/statistics/running_gradient_abstract.h index b38060502..e5f007fb1 100644 --- a/dlib/statistics/running_gradient_abstract.h +++ b/dlib/statistics/running_gradient_abstract.h @@ -65,6 +65,19 @@ namespace dlib of this line. !*/ + double intercept ( + ) const; + /*! + requires + - current_n() > 0 + ensures + - This class fits a line to the time series data given to add(). This + function returns the intercept of that line while gradient() returns the + slope of that line. This means that, for example, the next point that + add() will see, as predicted by this best fit line, is the value + intercept() + current_n()*gradient(). + !*/ + double standard_error ( ) const; /*!