View Javadoc
1   package org.djutils.stats.summarizers.quantileaccumulator;
2   
3   import org.djutils.stats.summarizers.Tally;
4   
5   /**
6    * Interface for quantile accumulator. <br>
7    * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
8    */
9   public interface QuantileAccumulator
10  {
11      /**
12       * Ingest one value with weight 1. Should be called only from the Tally object and AFTER processing the value in the tally.
13       * @param value double; the value
14       * @return double; the registered value
15       * @throws IllegalArgumentException when the registered value is NaN
16       */
17      double register(double value);
18  
19      /**
20       * Compute (or approximate) the value that corresponds to the given fraction (percentile).
21       * @param tally Tally; the tally object that accumulates mean, minimum, maximum, count, etc.
22       * @param probability double; value between 0.0 and 1.0 (both inclusive)
23       * @return double; the computed or approximated quantile value
24       * @throws IllegalArgumentException when the probability is less than 0 or larger than 1
25       * @throws NullPointerException when tally is null
26       */
27      double getQuantile(Tally tally, double probability);
28      
29      /**
30       * Get, or estimate fraction of registered values between -infinity up to and including a given quantile.
31       * @param tally Tally; the tally object that accumulates mean, minimum, maximum, count, etc.
32       * @param quantile double; the given quantile
33       * @return double; the estimated or observed fraction of registered values between -infinity up to and including the given
34       *         quantile. When this QuantileAccumulator has registered zero values; this method shall return NaN.
35       * @throws IllegalArgumentException when quantile is NaN
36       */
37      double getCumulativeProbability(Tally tally, double quantile) throws IllegalArgumentException;
38  
39      /**
40       * Reset (clear all accumulated information).
41       */
42      void initialize();
43  
44  }