Class PROMedSRobustEstimator<T>

java.lang.Object
com.irurueta.numerical.robust.RobustEstimator<T>
com.irurueta.numerical.robust.PROMedSRobustEstimator<T>
Type Parameters:
T - type of object to be estimated.

public class PROMedSRobustEstimator<T> extends RobustEstimator<T>
This class implements PROMedS (PROgressive least Median Sample) algorithm to robustly estimate a data model. This algorithm is a mixture between LMedS and PROSAC, taking the best of both. Firstly, it has the advantage that no threshold is required to be set beforehand, the same as LMedS. Threshold to determine inliers is computed dynamically, which helps for an easier setup that is problem independent and depending on the accuracy of the inliers, results will be more accurate than RANSAC or PROSAC, just the same as LMedS. On the other hand, if certain information about the quality of the samples is available, as in PROSAC, the algorithm takes advantage of this additional information to prioritize the samples with higher quality in order to find a solution much faster than RANSAC or LMedS. Finally, if by any chance a threshold to determine inliers is also used, the algorithm will try to get the solution that better fits in a pure median of residuals model or in a threshold based one to determine inliers. Hence, PROMedS can be as fast as PROSAC (which is typically about 100x faster than RANSAC or LMedS), can obtain the same accuracy as LMedS (which can be much better than RANSAC or PROSAC in certain scenarios), and has an easier setup, which is problem independent because no threshold is required to be known beforehand although one can be provided as well.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Contains data related to inliers estimated in one iteration.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Data related to inliers found for best result.
    private T
    Best solution that has been found so far during an estimation.
    private double
    beta is the probability that a match is declared inlier by mistake, i.e.
    static final double
    Chi squared.
    private double
    Amount of confidence expressed as a value between 0 and 1.0 (which is equivalent to 100%).
    static final double
    Defines the default value for beta, which is the probability that a match is declared inlier by mistake, i.e.
    static final double
    Constant defining default confidence of the estimated result, which is 99%.
    static final double
    Defines the default value for the maximum probability that a solution with more than inliersNStar in U_nStar exist and was not found after k samples.
    static final double
    Default factor to normalize threshold to determine inliers.
    static final int
    Default maximum allowed number of iterations.
    static final double
    Default maximum allowed outliers proportion in the input data.
    static final boolean
    Indicates whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener.
    static final boolean
    Indicates whether the inlier threshold will be used to find inliers along with their median of residuals.
    private double
    eta0 is the maximum probability that a solution with more than inliersNStar inliers in U_nStar exists and was not found after k samples (typically set to 5%).
    private double
    Factor to normalize threshold to determine inliers.
    private int
    Number of iterations to be done to obtain required confidence.
    static final double
    Maximum allowed value for beta.
    static final double
    Maximum allowed confidence value.
    static final double
    Maximum allowed value for eta0.
    static final double
    Maximum allowed value for maximum allowed outliers proportion in the input data.
    private int
    Maximum allowed number of iterations.
    private double
    In this implementation, PROSAC won't stop before having reached the corresponding inliers rate on the complete data set.
    static final double
    Minimum allowed value for beta.
    static final double
    Minimum allowed confidence value.
    static final double
    Minimum allowed value for eta0.
    static final double
    Minimum allowed value for inlier factor.
    static final int
    Minimum allowed number of iterations.
    static final double
    Minimum allowed value for maximum allowed outliers proportion in the input data.
    static final double
    Constant to estimate standard deviation of residuals based on their median.
    private boolean
    Indicates whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener.
    Instance in charge of picking random subsets of samples.
    private boolean
    Flag indicating whether thresholds to determine inliers are used, or if only median of residuals is used.

    Fields inherited from class com.irurueta.numerical.robust.RobustEstimator

    DEFAULT_PROGRESS_DELTA, listener, locked, MAX_PROGRESS_DELTA, MIN_PROGRESS_DELTA, progressDelta
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
    Constructor with listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static <T> void
    computeInliers(T iterResult, int subsetSize, double inlierFactor, boolean useInlierThresholds, double inlierThreshold, double[] residualsTemp, LMedSRobustEstimatorListener<T> listener, com.irurueta.sorting.Sorter<Double> sorter, PROMedSRobustEstimator.PROMedSInliersData inliersData)
    Computes inliers data for current iteration.
    private static int
    computeIterations(double probInlier, int subsetSize, double confidence)
    Computes number of required iterations to achieve required confidence with current probability of inlier and sample subset size.
    private static int[]
    computeSortedQualityIndices(double[] qualityScores)
    Obtains indices of samples corresponding to samples ordered in descending quality scores.
    Robustly estimates an instance of T.
    Returns data related to inliers found for best result.
    Returns best solution that has been found so far during an estimation.
    double
    Returns beta, which is the probability that a match is declared inlier by mistake, i.e.
    double
    Returns amount of confidence expressed as a value between 0 and 1.0 (which is equivalent to 100%).
    double
    Return eta0, which is the maximum probability that a solution with more than inliersNStar inliers in U_nStar exists and was not found after k samples (typically set to 5%).
    double
    Returns factor to normalize or adjust threshold to determine inliers.
    Returns data about inliers once estimation has been done.
    int
    Maximum allowed number of iterations.
    double
    Returns maximum allowed outliers proportion in the input data.
    Returns method being used for robust estimation.
    int
    Returns number of iterations to be done to obtain required confidence.
    private static int
    imin(int subsetSize, int sampleSize, double beta)
    Non randomness states that i-m (where i is the cardinal of the set of inliers for a wrong model) follows the binomial distribution B(n,beta).
    boolean
    Indicates if estimator is ready to start the estimation process.
    boolean
    Returns boolean indicating whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener.
    boolean
    Returns flag indicating whether thresholds to determine inliers are used, or if only median of residuals is used.
    private void
    Keeps inliers data stored and initializes a new one with proper initial values.
    private static void
    reverse(int[] array)
    Reverses provided array.
    void
    setBeta(double beta)
    Sets beta, which is the probability that a match is declared inlier by mistake, i.e.
    void
    setConfidence(double confidence)
    Sets amount of confidence expressed as a value between 0 and 1.0 (which is equivalent to 100%).
    void
    setEta0(double eta0)
    Sets eta0, which is the maximum probability that a solution with more than inliersNStar inliers in U_nStar exists and was not found after k samples (typically set to 5%).
    void
    setInlierFactor(double inlierFactor)
    Sets factor to normalize or adjust threshold to determine inliers.
    void
    setMaxIterations(int maxIterations)
    Sets maximum allowed number of iterations.
    void
    setMaxOutliersProportion(double maxOutliersProportion)
    Sets maximum allowed outliers proportion in the input data.
    void
    setStopThresholdEnabled(boolean stopThresholdEnabled)
    Sets boolean indicating whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener.
    void
    setUseInlierThresholds(boolean useInlierThresholds)
    Sets flag indicating whether thresholds to determine inliers are used, or if only median of residuals is used.
    private static void
    transformIndices(int[] subsetIndices, int[] sortedIndices, int[] transformedSubsetIndices)
    Transforms indices picked by the subset selector into the indices where samples are actually localed by taking into account their original position before sorting quality scores.

    Methods inherited from class com.irurueta.numerical.robust.RobustEstimator

    getListener, getProgressDelta, isListenerAvailable, isLocked, setListener, setProgressDelta

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_CONFIDENCE

      public static final double DEFAULT_CONFIDENCE
      Constant defining default confidence of the estimated result, which is 99%. This means that with a probability of 99% estimation will be accurate because chosen sub-samples will be inliers.
      See Also:
    • DEFAULT_MAX_ITERATIONS

      public static final int DEFAULT_MAX_ITERATIONS
      Default maximum allowed number of iterations.
      See Also:
    • MIN_CONFIDENCE

      public static final double MIN_CONFIDENCE
      Minimum allowed confidence value.
      See Also:
    • MAX_CONFIDENCE

      public static final double MAX_CONFIDENCE
      Maximum allowed confidence value.
      See Also:
    • MIN_ITERATIONS

      public static final int MIN_ITERATIONS
      Minimum allowed number of iterations.
      See Also:
    • DEFAULT_STOP_THRESHOLD_ENABLED

      public static final boolean DEFAULT_STOP_THRESHOLD_ENABLED
      Indicates whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener. When this flag is enabled accuracy of PROMedS worsens to a lever similar to PROSAC but the number of iterations is reduced (i.e. less computational cost). If more accuracy is desired at the expense of some additional computation cost, then disable this flag. By default, stop threshold is enabled, so that computational cost is similar to RANSAC and only accuracy gets better if inliers are more accurate.
      See Also:
    • DEFAULT_MAX_OUTLIERS_PROPORTION

      public static final double DEFAULT_MAX_OUTLIERS_PROPORTION
      Default maximum allowed outliers proportion in the input data. This is used do determine the number of required iterations.
      See Also:
    • MIN_MAX_OUTLIERS_PROPORTION

      public static final double MIN_MAX_OUTLIERS_PROPORTION
      Minimum allowed value for maximum allowed outliers proportion in the input data.
      See Also:
    • MAX_MAX_OUTLIERS_PROPORTION

      public static final double MAX_MAX_OUTLIERS_PROPORTION
      Maximum allowed value for maximum allowed outliers proportion in the input data.
      See Also:
    • DEFAULT_ETA0

      public static final double DEFAULT_ETA0
      Defines the default value for the maximum probability that a solution with more than inliersNStar in U_nStar exist and was not found after k samples.
      See Also:
    • MIN_ETA0

      public static final double MIN_ETA0
      Minimum allowed value for eta0.
      See Also:
    • MAX_ETA0

      public static final double MAX_ETA0
      Maximum allowed value for eta0.
      See Also:
    • DEFAULT_BETA

      public static final double DEFAULT_BETA
      Defines the default value for beta, which is the probability that a match is declared inlier by mistake, i.e. the ratio of the "inlier" surface by the total surface. The inlier surface is a disc with radius 1.96s for homography/displacement computation, or a band with width 1.96*s*2 for epipolar geometry (s is the detection noise), and the total surface is the surface of the image.
      See Also:
    • MIN_BETA

      public static final double MIN_BETA
      Minimum allowed value for beta.
      See Also:
    • MAX_BETA

      public static final double MAX_BETA
      Maximum allowed value for beta.
      See Also:
    • DEFAULT_INLIER_FACTOR

      public static final double DEFAULT_INLIER_FACTOR
      Default factor to normalize threshold to determine inliers. This factor can be used to increase or lower the dynamically computed threshold so that the algorithm becomes more or less accurate. The stricter the threshold (lower factor), the more time the algorithm will need to converge, if it can converge. By default, the factor is 1.0, which makes the threshold to be computed as the median of residuals.
      See Also:
    • MIN_INLER_FACTOR

      public static final double MIN_INLER_FACTOR
      Minimum allowed value for inlier factor.
      See Also:
    • DEFAULT_USE_INLIER_THRESHOLD

      public static final boolean DEFAULT_USE_INLIER_THRESHOLD
      Indicates whether the inlier threshold will be used to find inliers along with their median of residuals.
      See Also:
    • STD_CONSTANT

      public static final double STD_CONSTANT
      Constant to estimate standard deviation of residuals based on their median.
      See Also:
    • CHI_SQUARED

      public static final double CHI_SQUARED
      Chi squared.
      See Also:
    • confidence

      private double confidence
      Amount of confidence expressed as a value between 0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.
    • maxIterations

      private int maxIterations
      Maximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval.
    • maxOutliersProportion

      private double maxOutliersProportion
      In this implementation, PROSAC won't stop before having reached the corresponding inliers rate on the complete data set. Maximum allowed outliers proportion in the input data: used to compute nIters (can be as high as 0.95).
    • eta0

      private double eta0
      eta0 is the maximum probability that a solution with more than inliersNStar inliers in U_nStar exists and was not found after k samples (typically set to 5%).
    • beta

      private double beta
      beta is the probability that a match is declared inlier by mistake, i.e. the ratio of the "inlier" surface by the total surface. The inlier surface is a disc with radius 1.96s for homography/displacement computation, or a band with width 1.96s*2 for epipolar geometry (s is the detection noise), and the total surface is the surface of the image YOU MUST ADJUST THIS VALUE, DEPENDING ON YOUR PROBLEM!.
    • subsetSelector

      private SubsetSelector subsetSelector
      Instance in charge of picking random subsets of samples.
    • iters

      private int iters
      Number of iterations to be done to obtain required confidence.
    • bestResult

      private T bestResult
      Best solution that has been found so far during an estimation.
    • bestInliersData

      Data related to inliers found for best result.
    • stopThresholdEnabled

      private boolean stopThresholdEnabled
      Indicates whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener. When this flag is enabled accuracy of PROMedS worsens to a lever similar to PROSAC but the number of iterations is reduced (i.e. less computational cost). If more accuracy is desired at the expense of some additional computation cost, then disable this flag.
    • inlierFactor

      private double inlierFactor
      Factor to normalize threshold to determine inliers. This factor can be used to increase or lower the dynamically computed threshold so that the algorithm becomes more or less accurate. The stricter the threshold (lower factor), the more time the algorithm will need to converge, if it can converge. By default, the factor is 1.0, which makes the threshold to be computed as the median of residuals.
    • useInlierThresholds

      private boolean useInlierThresholds
      Flag indicating whether thresholds to determine inliers are used, or if only median of residuals is used. When true, the algorithm will try to fit the best model, otherwise only median of residuals will be used.
  • Constructor Details

    • PROMedSRobustEstimator

      public PROMedSRobustEstimator()
      Constructor.
    • PROMedSRobustEstimator

      public PROMedSRobustEstimator(PROMedSRobustEstimatorListener<T> listener)
      Constructor with listener.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes, as well as in charge of picking samples and doing per-iteration estimations.
  • Method Details

    • getConfidence

      public double getConfidence()
      Returns amount of confidence expressed as a value between 0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.
      Returns:
      amount of confidence as a value between 0.0 and 1.0.
    • setConfidence

      public void setConfidence(double confidence) throws LockedException
      Sets amount of confidence expressed as a value between 0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.
      Parameters:
      confidence - confidence to be set as a value between 0.0 and 1.0.
      Throws:
      IllegalArgumentException - if provided value is not between 0.0 and 1.0.
      LockedException - if this estimator is locked because an estimation is being computed.
    • getMaxIterations

      public int getMaxIterations()
      Maximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval.
      Returns:
      maximum allowed number of iterations.
    • setMaxIterations

      public void setMaxIterations(int maxIterations) throws LockedException
      Sets maximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval.
      Parameters:
      maxIterations - maximum allowed number of iterations to be set.
      Throws:
      IllegalArgumentException - if provided value is less than 1.
      LockedException - if this estimator is locked because an estimation is being computed.
    • isStopThresholdEnabled

      public boolean isStopThresholdEnabled()
      Returns boolean indicating whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener. When this flag is enabled accuracy of PROMedS worsens to a lever similar to PROSAC but the number of iterations is reduced (i.e. less computational cost). If more accuracy is desired at the expense of some additional computation cost, then disable this flag.
      Returns:
      true if stop threshold is enabled, false otherwise.
    • setStopThresholdEnabled

      public void setStopThresholdEnabled(boolean stopThresholdEnabled) throws LockedException
      Sets boolean indicating whether the algorithm must stop prematurely when dynamically computed threshold using median of residuals has a value lower than provided threshold in listener. When this flag is enabled accuracy of PROMedS worsens to a lever similar to PROSAC but the number of iterations is reduced (i.e. less computational cost). If more accuracy is desired at the expense of some additional computation cost, then disable this flag.
      Parameters:
      stopThresholdEnabled - true if stop threshold is enabled, false otherwise.
      Throws:
      LockedException - if this estimator is locked because an estimation is being computed.
    • getInlierFactor

      public double getInlierFactor()
      Returns factor to normalize or adjust threshold to determine inliers. This factor can be used to increase or lower the dynamically computed threshold so that the algorithm becomes more or less accurate. The stricter the threshold (lower factor), the more time the algorithm will need to converge, if it can converge. By default, the factor is 1.0, which makes the threshold to be computed as the median of residuals.
      Returns:
      factor to normalize threshold to determine inliers.
    • setInlierFactor

      public void setInlierFactor(double inlierFactor) throws LockedException
      Sets factor to normalize or adjust threshold to determine inliers. This factor can be used to increase or lower the dynamically computed threshold so that the algorithm becomes more or less accurate. The stricter the threshold (lower factor), the more time the algorithm will need to converge, if it can converge. By default, the factor is 1.0, which makes the threshold to be computed as the median of residuals.
      Parameters:
      inlierFactor - inlier factor to be set.
      Throws:
      IllegalArgumentException - if provided value is less or equal than 0.0.
      LockedException - if this estimator is locked because an estimation is being computed.
    • isUseInlierThresholds

      public boolean isUseInlierThresholds()
      Returns flag indicating whether thresholds to determine inliers are used, or if only median of residuals is used. When true, the algorithm will try to fit the best model, otherwise only median of residuals will be used.
      Returns:
      true if best model is used (threshold or median), otherwise only median of residuals will be used.
    • setUseInlierThresholds

      public void setUseInlierThresholds(boolean useInlierThresholds) throws LockedException
      Sets flag indicating whether thresholds to determine inliers are used, or if only median of residuals is used. When true, the algorithm will try to fit the best model, otherwise only median of residuals will be used.
      Parameters:
      useInlierThresholds - true if best model is used (threshold or median), oitherwise only median of residuals will be used.
      Throws:
      LockedException - if this estimator is locked because an estimation is being computed.
    • getMaxOutliersProportion

      public double getMaxOutliersProportion()
      Returns maximum allowed outliers proportion in the input data. This is used to compute number of iterations to be done (nIters). It typically can be as high as 0.95. Higher values, up to 1 are possible but not recommended. In this implementation, PROSAC won't stop before having reached the corresponding inliers rate on the complete data set.
      Returns:
      maximum allowed outliers proportion in the input data.
    • setMaxOutliersProportion

      public void setMaxOutliersProportion(double maxOutliersProportion) throws LockedException
      Sets maximum allowed outliers proportion in the input data. This is used to compute number of iterations to be done (nIters). It typically can be as high as 0.95. Higher values, up to 1 are possible but not recommended. In this implementation, PROSAC won't stop before having reached the corresponding inliers rate on the complete data set.
      Parameters:
      maxOutliersProportion - maximum allowed outliers proportion in the input data.
      Throws:
      IllegalArgumentException - if provided value is less than 0.0 or greater than 1.0.
      LockedException - if this estimator is locked because an estimation is being computed.
    • getEta0

      public double getEta0()
      Return eta0, which is the maximum probability that a solution with more than inliersNStar inliers in U_nStar exists and was not found after k samples (typically set to 5%).
      Returns:
      eta0 value.
    • setEta0

      public void setEta0(double eta0) throws LockedException
      Sets eta0, which is the maximum probability that a solution with more than inliersNStar inliers in U_nStar exists and was not found after k samples (typically set to 5%).
      Parameters:
      eta0 - eta0 value to be set.
      Throws:
      IllegalArgumentException - if provided value is less than 0.0 or greater than 1.0.
      LockedException - if this estimator is locked because an estimation is being computed.
    • getBeta

      public double getBeta()
      Returns beta, which is the probability that a match is declared inlier by mistake, i.e. the ratio of the "inlier" surface by the total surface. The inlier surface is a disc with radius 1.96s for homography/displacement computation, or a band with width 1.96s*2 for epipolar geometry (s is the detection noise), and the total surface is the surface of the image YOU MUST ADJUST THIS VALUE, DEPENDING ON YOUR PROBLEM!
      Returns:
      beta value.
    • setBeta

      public void setBeta(double beta) throws LockedException
      Sets beta, which is the probability that a match is declared inlier by mistake, i.e. the ratio of the "inlier" surface by the total surface. The inlier surface is a disc with radius 1.96s for homography/displacement computation, or a band with width 1.96s*2 for epipolar geometry (s is the detection noise), and the total surface is the surface of the image YOU MUST ADJUST THIS VALUE, DEPENDING ON YOUR PROBLEM!
      Parameters:
      beta - beta value to be set.
      Throws:
      IllegalArgumentException - if provided value is less than 0.0 or greater than 1.0.
      LockedException - if this estimator is locked because an estimation is being computed.
    • getNIters

      public int getNIters()
      Returns number of iterations to be done to obtain required confidence. This does not need to be equal to the actual number of iterations the algorithm finally required to obtain a solution.
      Returns:
      number of iterations to be done to obtain required confidence.
    • getBestResult

      public T getBestResult()
      Returns best solution that has been found so far during an estimation.
      Returns:
      best solution that has been found so far during an estimation.
    • getBestInliersData

      protected PROMedSRobustEstimator.PROMedSInliersData getBestInliersData()
      Returns data related to inliers found for best result.
      Returns:
      data related to inliers found for best result.
    • isReady

      public boolean isReady()
      Indicates if estimator is ready to start the estimation process.
      Overrides:
      isReady in class RobustEstimator<T>
      Returns:
      true if ready, false otherwise.
    • estimate

      Robustly estimates an instance of T.
      Specified by:
      estimate in class RobustEstimator<T>
      Returns:
      estimated object.
      Throws:
      LockedException - if robust estimator is locked.
      NotReadyException - if provided input data is not enough to start the estimation.
      RobustEstimatorException - if estimation fails for any reason (i.e. numerical instability, no solution available, etc).
    • getInliersData

      public InliersData getInliersData()
      Returns data about inliers once estimation has been done.
      Specified by:
      getInliersData in class RobustEstimator<T>
      Returns:
      data about inliers or null if estimation has not been done.
    • getMethod

      public RobustEstimatorMethod getMethod()
      Returns method being used for robust estimation.
      Specified by:
      getMethod in class RobustEstimator<T>
      Returns:
      method being used for robust estimation.
    • transformIndices

      private static void transformIndices(int[] subsetIndices, int[] sortedIndices, int[] transformedSubsetIndices)
      Transforms indices picked by the subset selector into the indices where samples are actually localed by taking into account their original position before sorting quality scores.
      Parameters:
      subsetIndices - indices picked by the subset selector. These are positions after sorting. Must have the subset length.
      sortedIndices - indices relating sorted positions to their original positions. Each position i-th in the array refers to the original position before sorting. Must have the number of samples length.
      transformedSubsetIndices - array where result is stored. Must have the subset length.
    • computeInliers

      private static <T> void computeInliers(T iterResult, int subsetSize, double inlierFactor, boolean useInlierThresholds, double inlierThreshold, double[] residualsTemp, LMedSRobustEstimatorListener<T> listener, com.irurueta.sorting.Sorter<Double> sorter, PROMedSRobustEstimator.PROMedSInliersData inliersData)
      Computes inliers data for current iteration.
      Type Parameters:
      T - type of result to be estimated.
      Parameters:
      iterResult - result to be tested on current iteration.
      subsetSize - subset sample size to be picked on each iteration.
      inlierFactor - factor to adjust threshold to determine whether samples are inliers or not.
      useInlierThresholds - true to use thresholds to determine inliers, false otherwise.
      inlierThreshold - threshold to determine which samples are inliers.
      residualsTemp - temporal array to store residuals, since median computation requires modifying the original array.
      listener - listener to obtain residuals for samples.
      sorter - sorter instance to compute median of residuals.
      inliersData - inliers data to be reused on each iteration
    • computeSortedQualityIndices

      private static int[] computeSortedQualityIndices(double[] qualityScores) throws com.irurueta.sorting.SortingException
      Obtains indices of samples corresponding to samples ordered in descending quality scores.
      Parameters:
      qualityScores - quality scores associated to each sample to be used to obtain indices to sort samples in descending order of quality values.
      Returns:
      indices to sort samples in descending order of quality values.
      Throws:
      com.irurueta.sorting.SortingException - if sorting fails.
    • reverse

      private static void reverse(int[] array)
      Reverses provided array.
      Parameters:
      array - array to be reversed.
    • computeIterations

      private static int computeIterations(double probInlier, int subsetSize, double confidence)
      Computes number of required iterations to achieve required confidence with current probability of inlier and sample subset size.
      Parameters:
      probInlier - probability of inlier.
      subsetSize - sample subset size.
      confidence - required confidence of result.
      Returns:
      number of required iterations.
    • imin

      private static int imin(int subsetSize, int sampleSize, double beta)
      Non randomness states that i-m (where i is the cardinal of the set of inliers for a wrong model) follows the binomial distribution B(n,beta). For n big enough, B(n,beta) approximates to normal distribution N(mu, sigma^2) by the central limit theorem, with mu = n*beta and sigma = sqrt(n*beta*(1 - beta)). Psi, the probability that In_star out of n_star data points are by chance inliers to an arbitrary incorrect model, is set to 0.05 (5%, as in the original paper), and you must change the Chi2 value if you chose a different value for psi.
      Parameters:
      subsetSize - sample subset size.
      sampleSize - total number of samples.
      beta - beta value.
      Returns:
      i-m.
    • keepInliersData

      private void keepInliersData(PROMedSRobustEstimator.PROMedSInliersData inliersData, int totalSamples)
      Keeps inliers data stored and initializes a new one with proper initial values.
      Parameters:
      inliersData - inliers data to be stored.
      totalSamples - total number of samples.