1   package org.djutils.stats.summarizers.quantileaccumulator;
2   
3   import org.djutils.exceptions.Throw;
4   import org.djutils.stats.DistNormalTable;
5   import org.djutils.stats.summarizers.Tally;
6   
7   
8   
9   
10  
11  
12  
13  public class NoStorageAccumulator implements QuantileAccumulator
14  {
15      
16      @Override
17      public double ingest(final double value)
18      {
19          Throw.when(Double.isNaN(value), IllegalArgumentException.class, "accumulator can not accumlate NaN value");
20          return value;
21      }
22  
23      
24      @Override
25      public double getQuantile(final Tally tally, final double probability)
26      {
27          Throw.whenNull(tally, "tally cannot be null");
28          Throw.when(probability < 0 || probability > 1, IllegalArgumentException.class,
29                  "probability should be between 0 and 1 (inclusive)");
30          return DistNormalTable.getInverseCumulativeProbability(tally.getSampleMean(), Math.sqrt(tally.getSampleVariance()),
31                  probability);
32      }
33  
34      
35      @Override
36      public String toString()
37      {
38          return "NoStorageAccumulator";
39      }
40  
41      
42      @Override
43      public void initialize()
44      {
45          
46      }
47  
48  }