14#include <yarp/os/LogStream.h>
15#include <yarp/math/Math.h>
16#include <yarp/math/SVD.h>
20using namespace yarp::os;
21using namespace yarp::sig;
22using namespace yarp::math;
28 order(_order), N(_N), D(_D)
44 for (
unsigned int i=1; i<=
order; i++)
58 unsigned int i2=(
unsigned int)std::min(
x.length(),
y.length());
70 for (
unsigned int i=i1; i<i2; i++)
76 for (
unsigned int j=1; j<=
order; j++)
85 if (R.rows()>=R.cols())
88 return pinv(R.transposed()).transposed()*_y;
104 size_t dim=
elemList[0].data.length();
105 Vector esteem(dim,0.0);
115 int delta=(int)L-(
int)
N;
123 for (
unsigned int j=1; j<
N; j++)
130 yWarning()<<
"Provided non-increasing time vector";
136 for (
unsigned int i=0; i<dim; i++)
139 for (
unsigned int j=0; j<
N; j++)
147 for (
unsigned int n=n1;
n<=n2;
n++)
156 for (
unsigned int k=
N-
n; k<
N; k++)
207 unsigned int i2=(
unsigned int)std::min(
x.length(),
y.length());
221 for (
unsigned int i=i1; i<i2; i++)
229 double den=M*sum_xixi-sum_xi*sum_xi;
234 c[0]=(sum_yi*sum_xixi-sum_xi*sum_xiyi) / den;
237 c[1]=(M*sum_xiyi-sum_xi*sum_yi) / den;
virtual yarp::sig::Vector fit(const yarp::sig::Vector &x, const yarp::sig::Vector &y, const unsigned int n=0)
Redefine method to improve computation just for first-order estimator.
Basic element for adaptive polynomial fitting.
yarp::sig::Vector estimate()
Execute the algorithm upon the elements list, with the max deviation threshold given by D.
void feedData(const AWPolyElement &el)
Feed data into the algorithm.
virtual double eval(double x)
Evaluate regressor at certain point.
void reset()
Reinitialize the internal state.
virtual double getEsteeme()=0
Return the current estimation.
AWPolyEstimator(unsigned int _order, unsigned int _N, const double _D)
Create a polynomial estimator object of order _order on an adaptive window of a maximum length _N an ...
virtual yarp::sig::Vector fit(const yarp::sig::Vector &x, const yarp::sig::Vector &y, const unsigned int n=0)
Find the regressor which best fits in least square sense the last n data sample couples,...