PersistentStatistic.java

  1. package org.opentrafficsim.kpi.sampling.indicator;

  2. import org.djunits.unit.Unit;
  3. import org.djunits.value.vdouble.scalar.base.DoubleScalarRel;

  4. /**
  5.  * <p>
  6.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  7.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  8.  * </p>
  9.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  10.  * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
  11.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  12.  * @param <U> the unit type
  13.  * @param <T> type of the value
  14.  */
  15. @Deprecated // non-scalar statistics not yet implemented
  16. public class PersistentStatistic<U extends Unit<U>, T extends DoubleScalarRel<U, T>>
  17. {
  18.     /** Wrapped persistent. */
  19.     private final Persistent<U, T, ?> persistent;

  20.     /**
  21.      * Constructor.
  22.      * @param persistent the persistent statistic that gathers the data
  23.      */
  24.     public PersistentStatistic(final Persistent<U, T, ?> persistent)
  25.     {
  26.         this.persistent = persistent.copy();
  27.     }

  28.     /**
  29.      * @param alpha confidence level
  30.      * @return both-side confidence interval
  31.      */
  32.     public ConfidenceInterval<T> getConfidenceInterval(final double alpha)
  33.     {
  34.         return this.persistent.getConfidenceInterval(alpha);
  35.     }

  36.     /**
  37.      * @param alpha confidence level
  38.      * @param side side of confidence interval
  39.      * @return confidence interval
  40.      */
  41.     public ConfidenceInterval<T> getConfidenceInterval(final double alpha, final IntervalSide side)
  42.     {
  43.         return this.persistent.getConfidenceInterval(alpha, side);
  44.     }

  45.     /**
  46.      * @return sum.
  47.      */
  48.     public T getSum()
  49.     {
  50.         return this.persistent.getSum();
  51.     }

  52.     /**
  53.      * @return min.
  54.      */
  55.     public T getMin()
  56.     {
  57.         return this.persistent.getMin();
  58.     }

  59.     /**
  60.      * @return max.
  61.      */
  62.     public T getMax()
  63.     {
  64.         return this.persistent.getMax();
  65.     }

  66.     /**
  67.      * @return mean.
  68.      */
  69.     public T getMean()
  70.     {
  71.         return this.persistent.getMean();
  72.     }

  73.     /**
  74.      * @return stDev.
  75.      */
  76.     public T getStDev()
  77.     {
  78.         return this.persistent.getStDev();
  79.     }

  80.     /**
  81.      * @return variance.
  82.      */
  83.     public double getVariance()
  84.     {
  85.         return this.persistent.getVariance();
  86.     }

  87.     /**
  88.      * @return n.
  89.      */
  90.     public long getN()
  91.     {
  92.         return this.persistent.getN();
  93.     }

  94.     @Override
  95.     public final String toString()
  96.     {
  97.         return "PersistentStatistic [persistent=" + this.persistent + "]";
  98.     }

  99. }