loupe.sserror#
- class loupe.sserror(model, data, mask=None, gain_bias_invariant=True)[source]#
Compute the normalized sum squared error between two arrays.
The normalized sum squared error between ideal data f and estimated data g is given by
\[\mbox{error} = \frac{1}{N}\sum_n \frac{\sum{\left|g(n,x,y)-f(n,x,y)\right|^2}}{\sum{\left|f(n,x,y)\right|^2}}\]for \(n = 1, 2, ... N\) independent measurements.
If gain_bias_invariant is
True
, the error metric is computed such that the result is independent of relative scaling (gain) and offset (bias) differences between f and g [1].- Parameters:
model (array_like) – Estimated or modeled data
data (array_like) – Ideal or measured data
mask (array_like, optional) – Mask applied to the inputs where a True value indicates that the corresponding element of the array is invalid. Mask must either have the same shape as the inputs or be broadcastable to the same shape and contain entries that are castable to bool. If None (default), the inputs are not masked.
gain_bias_invariant (bool, optional) – If True (default), the error is computed to be independent of any gain or bias differences between the inputs.
- Returns:
error – Normalized root mean squared error
- Return type:
float
References
[1] S. Thurman and J. Fienup, “Phase retrieval with signal bias”, J. Opt. Soc. Am. A/Vol. 26, No. 4 (2009)
[2] A. Jurling and J. Fienup, “Applications of algorithmic differentiation to phase retrieval algorithms”, J. Opt. Soc. Am. A/Vol. 31, No. 7 (2014)