Skip to main content

assert_max_residual

Macro assert_max_residual 

Source
macro_rules! assert_max_residual {
    ($fit:expr, $max:expr $(, $msg:literal $(, $($args:tt),*)?)?) => { ... };
    ($fit:expr, $max:expr, $tolerance:expr $(, $msg:literal $(, $($args:tt),*)?)?) => { ... };
}
Expand description

Asserts that at least a certain proportion of residuals (the differences between the observed and predicted values) of a fit are below a certain threshold.

This ensures that residuals are not too large, i.e., the fit is sufficiently close to the data. Unlike assert_residuals_normal, this checks magnitude, not distribution shape.

§Parameters

  • fit: The curve fit to test.
  • max: Maximum allowed residual magnitude.
  • tolerance: Proportion of residuals that must be below max. Defaults to 0.95 if omitted.

§Panics

Panics if the proportion of residuals below max is less than tolerance. If the plotting feature is enabled, a failure plot is generated.

§Example

let fit = MonomialFit::new(&[(0.0, 0.0), (1.0, 1.0)], 1).unwrap();
assert_max_residual!(fit, 0.01);