8#ifndef META_OCEAN_GEOMETRY_ESTIMATOR_H
9#define META_OCEAN_GEOMETRY_ESTIMATOR_H
133 template <EstimatorType tEstimator>
141 template <EstimatorType tEstimator>
166 template <EstimatorType tEstimator>
187 template <EstimatorType tEstimator>
207 template <EstimatorType tEstimator>
226 template <EstimatorType tEstimator>
246 template <EstimatorType tEstimator>
268 template <EstimatorType tEstimator>
269 static inline Scalar determineSigma(
const Scalar* errors,
const unsigned int* indices,
const size_t numberIndices,
const size_t modelParameters);
290 template <EstimatorType tEstimator>
312 template <EstimatorType tEstimator>
334 template <Estimator::EstimatorType tEstimator>
375 template <EstimatorType tEstimator>
379template <Estimator::EstimatorType tEstimator>
408 ocean_assert(
false &&
"Invalid estimator!");
412template <Estimator::EstimatorType tEstimator>
427template <Estimator::EstimatorType tEstimator>
430 ocean_assert(
false &&
"Invalid estimator type!");
438 ocean_assert_and_suppress_unused(sigma ==
Scalar(0), sigma);
442 return value * value *
Scalar(0.5);
448 ocean_assert_and_suppress_unused(sigma ==
Scalar(0), sigma);
461 ocean_assert(sigma > 0);
465 if (absValue <= sigma)
467 return value * value *
Scalar(0.5);
470 return sigma * (absValue - sigma *
Scalar(0.5));
479 ocean_assert(sigma > 0);
481 const Scalar sqrSigma6 = sigma * sigma *
Scalar(1.0 / 6.0);
487 return sqrSigma6 * (
Scalar(1) - tmp * tmp * tmp);
498 ocean_assert(sigma > 0);
526 ocean_assert(
false &&
"Invalid estimator!");
530template <Estimator::EstimatorType tEstimator>
533 ocean_assert(
false &&
"Invalid estimator type!");
541 ocean_assert_and_suppress_unused(sqrSigma ==
Scalar(0), sqrSigma);
545 return sqrValue *
Scalar(0.5);
551 ocean_assert_and_suppress_unused(sqrSigma ==
Scalar(0), sqrSigma);
564 ocean_assert(sqrSigma > 0);
566 if (sqrValue <= sqrSigma)
568 return sqrValue *
Scalar(0.5);
580 ocean_assert(sqrSigma > 0);
582 if (sqrValue <= sqrSigma)
586 return sqrSigma *
Scalar(1.0 / 6.0) * (
Scalar(1) - tmp * tmp * tmp);
589 return sqrSigma *
Scalar(1.0 / 6.0);
597 ocean_assert(sqrSigma > 0);
625 ocean_assert(
false &&
"Invalid estimator!");
629template <Estimator::EstimatorType tEstimator>
632 ocean_assert(
false &&
"Invalid estimator!");
640 ocean_assert_and_suppress_unused(sigma ==
Scalar(0), sigma);
648 ocean_assert_and_suppress_unused(sigma ==
Scalar(0), sigma);
658 ocean_assert(sigma > 0);
662 if (absValue <= sigma)
667 return std::min(
Numeric::ratio(sigma, absValue, maximalWeight()), maximalWeight());
673 ocean_assert(sigma > 0);
677 if (absValue > sigma)
688 ocean_assert(sigma > 0);
716 ocean_assert(
false &&
"Invalid estimator!");
720template <Estimator::EstimatorType tEstimator>
723 ocean_assert(
false &&
"Invalid estimator!");
730 ocean_assert_and_suppress_unused(sqrSigma ==
Scalar(0), sqrSigma);
738 ocean_assert(sqrValue >= 0);
739 ocean_assert_and_suppress_unused(sqrSigma ==
Scalar(0), sqrSigma);
747 ocean_assert(sqrValue >= 0 && sqrSigma > 0);
749 if (sqrValue <= sqrSigma)
760 ocean_assert(sqrSigma > 0);
762 if (sqrValue > sqrSigma)
773 ocean_assert(sqrSigma > 0);
801 ocean_assert(
false &&
"Invalid estimator!");
805template <Estimator::EstimatorType tEstimator>
808 ocean_assert(number > 0);
812 if (number <= modelParameters)
841 ocean_assert(
false &&
"Invalid estimator!");
845template <Estimator::EstimatorType tEstimator>
848 ocean_assert(errors !=
nullptr);
849 ocean_assert(indices !=
nullptr);
850 ocean_assert(numberIndices > 0);
851 ocean_assert(modelParameters >= 1);
854 Scalars subsetErrors(numberIndices);
855 for (
size_t n = 0; n < numberIndices; ++n)
857 subsetErrors[n] = errors[indices[n]];
862 if (numberIndices <= modelParameters)
891 ocean_assert(
false &&
"Invalid estimator!");
895template <Estimator::EstimatorType tEstimator>
898 ocean_assert(sqrErrors !=
nullptr);
899 ocean_assert(number > 0);
903 if (number <= modelParameters)
932 ocean_assert(
false &&
"Invalid estimator!");
936template <Estimator::EstimatorType tEstimator>
939 ocean_assert(sqrErrors !=
nullptr);
940 ocean_assert(indices !=
nullptr);
941 ocean_assert(numberIndices > 0);
944 Scalars subsetSqrErrors(numberIndices);
945 for (
size_t n = 0; n < numberIndices; ++n)
947 subsetSqrErrors[n] = sqrErrors[indices[n]];
952 if (numberIndices <= modelParameters)
981 ocean_assert(
false &&
"Invalid estimator!");
985template <Estimator::EstimatorType tEstimator>
988 ocean_assert(sqrErrors !=
nullptr && number >= 1);
989 ocean_assert(modelParameters >= 1);
996 for (
size_t n = 0; n < number; ++n)
1015template <Estimator::EstimatorType tEstimator>
1018 ocean_assert(
false &&
"Invalid estimator type!");
This class implements robust estimator functions.
Definition Estimator.h:27
static Scalar robustWeight(const Scalar value, const Scalar sigma=0)
Returns the weight in relation to a error for a given residual error and a specified estimator.
Definition Estimator.h:630
static Scalar robustWeightSquare(const Scalar sqrValue, const Scalar sqrSigma=0)
Returns the weight in relation to a squared error for a given residual error and a specified estimato...
Definition Estimator.h:721
static std::string translateEstimatorType(const EstimatorType estimatorType)
Translates a given estimator type into a readable string.
static constexpr Scalar invMaximalWeight()
Returns the inverse maximal weight for any estimator which is used to clamp extremely high weights (f...
Definition Estimator.h:1010
static Scalar determineSigmaSquare(const Scalar *sqrErrors, const size_t number, const size_t modelParameters)
Determines the squared sigma for a specific set of squared residual errors and a specified estimator.
Definition Estimator.h:896
static Scalar determineRobustError(const Scalar *sqrErrors, const size_t number, const size_t modelParameters)
Determines the overall robust error for set of given squared errors, a specified estimator and the di...
Definition Estimator.h:986
static constexpr Scalar maximalWeight()
Returns the maximal weight for any estimator which is used to clamp extremely high weights (for tiny ...
Definition Estimator.h:1005
static EstimatorType translateEstimatorType(const std::string &estimatorType)
Translates a readable name of an estimator type to it's value.
static constexpr bool needSigma()
Returns whether an estimator needs a standard deviation for computation.
Definition Estimator.h:380
static const EstimatorTypes & estimatorTypes()
Returns all existing valid estimator types.
std::vector< EstimatorType > EstimatorTypes
Definition of a vector holding estimator types.
Definition Estimator.h:124
EstimatorType
Definition of individual robust estimator types.
Definition Estimator.h:34
@ ET_HUBER
The Huber estimator type.
Definition Estimator.h:84
@ ET_TUKEY
The Tukey estimator.
Definition Estimator.h:102
@ ET_SQUARE
The standard square error estimator (L2).
Definition Estimator.h:52
@ ET_LINEAR
The linear estimator (L1).
Definition Estimator.h:66
@ ET_INVALID
An invalid estimator type.
Definition Estimator.h:38
@ ET_CAUCHY
The Cauchy estimator.
Definition Estimator.h:118
static constexpr bool isStandardEstimator()
Returns whether an estimator is the standard square error estimator.
Definition Estimator.h:413
static Scalar robustError(const Scalar value, const Scalar sigma=0)
Returns the robust error of a residual error for a specified estimator.
Definition Estimator.h:428
static Scalar robustErrorSquare(const Scalar sqrValue, const Scalar sqrSigma=0)
Returns the robust error of a squared residual error for a specified estimator.
Definition Estimator.h:531
static Scalar sigmaTuningConstant()
Returns the tuning constant allowing to determine a 95 percent efficiency on the standard normal dist...
Definition Estimator.h:1016
static Scalar determineSigma(const Scalar *errors, const size_t number, const size_t modelParameters)
Determines the sigma for a specific set of residual errors and a specified estimator.
Definition Estimator.h:806
static constexpr Scalar weakEps()
static Scalar log(const Scalar value)
static Scalar abs(const Scalar value)
static Scalar sqrt(const Scalar value)
static constexpr Scalar eps()
static constexpr Scalar ratio(const Scalar nominator, const Scalar denominator, const Scalar fallback=Scalar(1))
static constexpr Scalar sqr(const Scalar value)
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
float Scalar
Definition of a scalar type.
Definition Math.h:129
Namespace of the Geometry library.
Definition AbsoluteTransformation.h:20
The namespace covering the entire Ocean framework.
Definition Accessor.h:15