• Main Page
  • Related Pages
  • Classes
  • Files
  • Examples
  • File List
  • File Members

ErrorFunction.cpp

Go to the documentation of this file.
00001 //===========================================================================
00064 //===========================================================================
00065 
00066 #include <ReClaM/ErrorFunction.h>
00067 #include <math.h>
00068 
00069 
00070 ErrorFunction::ErrorFunction()
00071 {
00072     epsilon = 1e-2;
00073 }
00074 
00075 ErrorFunction::~ErrorFunction()
00076 {
00077 }
00078 
00079 
00080 double ErrorFunction::errorDerivative(Model& model, const Array<double>& input, const Array<double>& target, Array<double>& derivative)
00081 {
00082     int p, pc = model.getParameterDimension();
00083     derivative.resize(pc, false);
00084 
00085     double ret = error(model, input, target);
00086     double temp, eps, e;
00087     for (p = 0; p < pc; p++)
00088     {
00089         temp = model.getParameter(p);
00090         eps = epsilon * temp;
00091         if (fabs(eps) < fabs(0.1 * epsilon)) eps = epsilon;
00092         model.setParameter(p, temp + eps);
00093         e = error(model, input, target);
00094         derivative(p) = (e - ret) / eps;
00095         model.setParameter(p, temp);
00096     }
00097 
00098     return ret;
00099 }
00100 
  • Shark Main Page
  • Array
  • Rng
  • LinAlg
  • FileUtil
  • EALib
  • MOO-EALib
  • ReClaM
  • Fuzzy
  • Mixture
  • Tutorials
  • FAQ