Accuracy of an approximating function.
Description
This routine computes several indicators to evaluate the accuracy of a function $f:\mathbb{R}^n\rightarrow\mathbb{R}^{n_1\times n_2}$, which approximates a set of samples $\left\{y_k\in\mathbb{R}^{n_1\times n_2}, k\in [1, N]\right\}$ obtained for different values $\left\{x_k\in\mathbb{R}^n,k \in [1, N]\right\}$ of some explanatory variables $x$. With $e_k=y_k-f(x_k)$ and $\|e(i_1,i_2)\|=\sqrt{\sum\limits_{k=1}^N e_k(i_1,i_2)^2}$, the following quantities are computed for each entry $i_1\in [1, n_1]$ and $i_2\in [1, n_2]$:
- global relative error:
relerr(i1,i2)
$=\displaystyle\frac{\|e(i_1,i_2)\|}{\|y(i_1,i_2)\|}$ - root-mean-square error:
rmserr(i1,i2)
$=\displaystyle\frac{\|e(i_1,i_2)\|}{\sqrt{N}}$ - maximum local absolute error:
abserr(i1,i2)
$=\max\limits_{k\in [1,N]}|e_k(i_1,i_2)|$
Syntax
[relerr,rmserr,abserr,absind]=errapprox(Y,fdata)
[relerr,rmserr,abserr,absind]=errapprox(X,Y,names,flfr)
Input arguments
X | Values $\left\{x_k\in\mathbb{R}^n,k \in [1, N]\right\}$ of the explanatory variables $x$ ($n\times N$ array, where X(:,k) corresponds to $x_k$). |
Y | Samples $\left\{y_k\in\mathbb{R}^{n_1\times n_2}, k\in [1, N]\right\}$ ($n_1\times n_2\times N$ array where Y(:,:,k) corresponds to $y_k$ in the general case, or possibly $1\times N$ array where Y(k) corresponds to $y_k$ if $n_1=n_2=1$). |
names | Names of the explanatory variables $x$ ($1\times n$ cell array of strings). |
fdata | Values $\left\{f(x_k)\in\mathbb{R}^{n_1\times n_2},k \in [1, N]\right\}$ of the approximating function $f$ (same size as Y ). |
flfr | Linear fractional representation of the approximating function $f$ (GSS object if the GSS library is installed, LFR object otherwise if the LFR toolbox is installed). |
Output arguments
relerr | Global relative error for each entry ($n_1\times n_2$ array). |
rmserr | Root-mean-square error for each entry ($n_1\times n_2$ array). |
abserr | Maximum local absolute error for each entry ($n_1\times n_2$ array). |
absind | Index of the sample at which the maximum local absolute error is computed for each entry ($n_1\times n_2$ array). |