lp_error()#

lp_error(Qtrue, Qapprox, p=2, normalize=False)[source]#

Compute the absolute and relative lp-norm errors between the snapshot sets Qtrue and Qapprox, where Qapprox approximates to Qtrue:

absolute_error_j = ||Qtrue_j - Qapprox_j||_p, relative_error_j = ||Qtrue_j - Qapprox_j||_p / ||Qtrue_j||_p.

Parameters
Qtrue(n, k) or (n,) ndarray

“True” data. Each column is one snapshot, i.e., Qtrue[:, j] is the data at some time t[j]. If one-dimensional, all of Qtrue is a single snapshot.

Qapprox(n, k) or (n,) ndarray

An approximation to Qtrue, i.e., Qapprox[:, j] approximates Qtrue[:, j] and corresponds to some time t[j]. If one-dimensional, all of Qapprox is a single snapshot approximation.

pfloat

Order of the lp norm (default p=2 is the Euclidean norm). Used as the ord argument for scipy.linalg.norm(); see options at docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.norm.html.

normalizebool

If true, compute the normalized absolute error instead of the relative error, defined by

normalized_absolute_error_j

= ||Qtrue_j - Qapprox_j||_2 / max_k{||Qtrue_k||_2}.

Returns
abs_err(k,) ndarray or float

Absolute error of each pair of snapshots Qtrue[:, j] and Qapprox[:, j]. If Qtrue and Qapprox are one-dimensional, Qtrue and Qapprox are treated as single snapshots, so the error is a float.

rel_err(k,) ndarray or float

Relative or normed absolute error of each pair of snapshots Qtrue[:, j] and Qapprox[:, j]. If Qtrue and Qapprox are one-dimensional, Qtrue and Qapprox are treated as single snapshots, so the error is a float.