View Javadoc
1   /*
2    * Copyright (C) 2015 Alberto Irurueta Carro (alberto@irurueta.com)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.irurueta.numerical.robust;
17  
18  import java.util.List;
19  
20  /**
21   * Listener to get data samples and residuals for LMedS method.
22   *
23   * @param <T> type of object to be estimated.
24   */
25  public interface LMedSRobustEstimatorListener<T>
26          extends RobustEstimatorListener<T> {
27      /**
28       * Returns total number of samples to be randomly processed.
29       *
30       * @return total number of samples.
31       */
32      int getTotalSamples();
33  
34      /**
35       * Returns size of subsets of samples to be selected.
36       *
37       * @return size of subsets of samples to be selected.
38       */
39      int getSubsetSize();
40  
41      /**
42       * Estimates a list of possible preliminary solutions to be used during an
43       * iteration of LMedS robust estimator.
44       *
45       * @param samplesIndices indices of random subset of samples that have been
46       *                       picked.
47       * @param solutions      list where possible preliminary solutions to be used
48       *                       during an iteration of LMedS robust estimator will be stored. Provided
49       *                       list will always be empty, and it is up to the implementor to fill it
50       *                       with preliminary solutions based on provided sample indices.
51       */
52      void estimatePreliminarSolutions(
53              final int[] samplesIndices, final List<T> solutions);
54  
55      /**
56       * Computes residual for sample located at i-th position using estimation
57       * on current iteration.
58       *
59       * @param currentEstimation a preliminar estimation that has been found for
60       *                          current iteration.
61       * @param i                 position of sample to be checked.
62       * @return residual for i-th sample.
63       */
64      double computeResidual(final T currentEstimation, final int i);
65  }