7 #include <boost/numeric/ublas/vector.hpp>
8 #include <boost/numeric/ublas/vector_proxy.hpp>
11 using namespace boost::numeric::ublas;
12 using namespace gplib;
25 const int datasize = 500;
26 const int filterlength = 20;
27 const int inputlength = 100;
28 gplib::rvec Data(datasize);
29 for (
int i = 0; i < datasize; ++i)
30 Data(i) = sin(static_cast<double> (i) / 0.9) + cos(
31 static_cast<double> (i) / 2.7) + (0.5 - Random.
GetNumber()) * 0.1;
34 gplib::rvec Input(inputlength);
35 gplib::rvec Prediction(datasize);
36 for (
int i = 0; i < inputlength; ++i)
39 Prediction(i) = Data(i);
43 for (
int i = inputlength - filterlength; i < datasize - filterlength; ++i)
45 vector_range<vector<double> >
46 vr(Prediction, range(i, i + filterlength));
47 Prediction(i + filterlength) = inner_prod(Wiener.
GetWeights(), vr);
49 std::ofstream outfile(
"out");
50 for (
int i = 0; i < datasize; ++i)
51 outfile << i <<
" " << Data(i) <<
" " << Prediction(i) << std::endl;
const gplib::rvec & GetWeights()
Return the current set of weights.
virtual void AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired)
Calculate the prediction coefficients, the contents of Desired are ignored, this function has to be i...