projection_error()#
- BasisMulti.projection_error(state, relative=True) float[source]#
Compute the error of the basis representation of a state or states.
This function computes \(\frac{\|\Q - \mathcal{P}(\Q)\|}{\|\Q\|}\), where \(\Q\) is the
stateand \(\mathcal{P}\) is the projection defined byproject(). Ifstateis one-dimensional then \(||\cdot||\) is the vector 2-norm. Ifstateis two-dimensional then \(||\cdot||\) is the Frobenius norm.- Parameters:
- state(n,) or (n, k) ndarray
Matrix of n-dimensional state vectors, or a single state vector. The first
full_variable_sizes[0]entries correspond to the first state variable, the nextfull_variable_sizes[1]entries correspond to the second state variable, and so on.- relativebool
If
True(default), return the relative projection errornorm(state - project(state)) / norm(state). IfFalse, return the absolute projection errornorm(state - project(state)).
- Returns:
- float
Relative error of the projection (
relative=True) or absolute error of the projection (relative=False).