RMS error on the test set INPUT PARAMETERS: LM - linear model XY - test set NPoints - test set size RESULT: root mean square error. -- ALGLIB -- Copyright 30.08.2008 by Bochkanov Sergey *************************************************************************/
| 487 | Copyright 30.08.2008 by Bochkanov Sergey |
| 488 | *************************************************************************/ |
| 489 | double lrrmserror(const linearmodel& lm, |
| 490 | const ap::real_2d_array& xy, |
| 491 | int npoints) |
| 492 | { |
| 493 | double result; |
| 494 | int i; |
| 495 | double v; |
| 496 | int offs; |
| 497 | int nvars; |
| 498 | |
| 499 | ap::ap_error::make_assertion(ap::round_f(lm.w(1))==lrvnum, "LINREG: Incorrect LINREG version!"); |
| 500 | nvars = ap::round_f(lm.w(2)); |
| 501 | offs = ap::round_f(lm.w(3)); |
| 502 | result = 0; |
| 503 | for(i = 0; i <= npoints-1; i++) |
| 504 | { |
| 505 | v = ap::vdotproduct(&xy(i, 0), 1, &lm.w(offs), 1, ap::vlen(0,nvars-1)); |
| 506 | v = v+lm.w(offs+nvars); |
| 507 | result = result+ap::sqr(v-xy(i,nvars)); |
| 508 | } |
| 509 | result = sqrt(result/npoints); |
| 510 | return result; |
| 511 | } |
| 512 | |
| 513 | |
| 514 | /************************************************************************* |
no test coverage detected