added test for negative error in Huber Robust noise model

release/4.3a0
Varun Agrawal 2019-09-18 16:13:09 -04:00
parent d3305d27f4
commit 60f5ee7cf1
1 changed files with 8 additions and 3 deletions

View File

@ -452,19 +452,24 @@ TEST(NoiseModel, WhitenInPlace)
/*
* These tests are responsible for testing the weight functions for the m-estimators in GTSAM.
* The weight function is related to the analytic derivative of the residual function. See
* http://research.microsoft.com/en-us/um/people/zhang/INRIA/Publis/Tutorial-Estim/node24.html
* https://members.loria.fr/MOBerger/Enseignement/Master2/Documents/ZhangIVC-97-01.pdf
* for details. This weight function is required when optimizing cost functions with robust
* penalties using iteratively re-weighted least squares.
*/
TEST(NoiseModel, robustFunctionHuber)
{
const double k = 5.0, error1 = 1.0, error2 = 10.0;
const double k = 5.0, error1 = 1.0, error2 = 10.0, error3 = -10.0, error4 = -1.0;
const mEstimator::Huber::shared_ptr huber = mEstimator::Huber::Create(k);
const double weight1 = huber->weight(error1),
weight2 = huber->weight(error2);
weight2 = huber->weight(error2),
weight3 = huber->weight(error3),
weight4 = huber->weight(error4);
DOUBLES_EQUAL(1.0, weight1, 1e-8);
DOUBLES_EQUAL(0.5, weight2, 1e-8);
// Test negative value to ensure we take absolute value of error.
DOUBLES_EQUAL(0.5, weight3, 1e-8);
DOUBLES_EQUAL(1.0, weight4, 1e-8);
}
TEST(NoiseModel, robustFunctionGemanMcClure)