MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / lravgerror

Function lravgerror

src/linreg.cpp:528–550  ·  view source on GitHub ↗

Average error on the test set INPUT PARAMETERS: LM - linear model XY - test set NPoints - test set size RESULT: average error. -- ALGLIB -- Copyright 30.08.2008 by Bochkanov Sergey *************************************************************************/

Source from the content-addressed store, hash-verified

526 Copyright 30.08.2008 by Bochkanov Sergey
527*************************************************************************/
528double lravgerror(const linearmodel& lm,
529 const ap::real_2d_array& xy,
530 int npoints)
531{
532 double result;
533 int i;
534 double v;
535 int offs;
536 int nvars;
537
538 ap::ap_error::make_assertion(ap::round_f(lm.w(1))==lrvnum, "LINREG: Incorrect LINREG version!");
539 nvars = ap::round_f(lm.w(2));
540 offs = ap::round_f(lm.w(3));
541 result = 0;
542 for(i = 0; i <= npoints-1; i++)
543 {
544 v = ap::vdotproduct(&xy(i, 0), 1, &lm.w(offs), 1, ap::vlen(0,nvars-1));
545 v = v+lm.w(offs+nvars);
546 result = result+fabs(v-xy(i,nvars));
547 }
548 result = result/npoints;
549 return result;
550}
551
552
553/*************************************************************************

Callers 1

lrinternalFunction · 0.85

Calls 2

round_fFunction · 0.85
vdotproductFunction · 0.85

Tested by

no test coverage detected