[−][src]Trait sample_consensus::Model
A model is a best-fit of at least some of the underlying data. You can compute residuals in respect to the model.
Required methods
fn residual(&self, data: &Data) -> f32
Note that the residual error is returned as a 32-bit float. This might be harder to preserve precision with than a 64-bit float, but it will be faster to perform RANSAC if care is taken to avoid round-off error using Kahan's algorithm or using Pairwise summation. If the number of datapoints is small, then there should be little issue with the accumulation of round-off error and 32-bit floats should work without any concern.
Here are some helpers to allow you to perform less lossy summation:
- Kahan Summation
- Pairwise Summation
let sum = estimator.residuals(data).tree_fold1(|a, b| a + b).unwrap_or(0.0)
If all you wish to do is filter data points out if they are above a certian threshold of error then the 32-bit float's precision will be no issue for you. Most fast RANSAC algorithms utilize this approach and score models based only on their inlier count.