View Javadoc
1   package org.opentrafficsim.kpi.sampling.indicator;
2   
3   import org.djunits.value.vdouble.scalar.AbstractDoubleScalarRel;
4   import org.djunits.value.vdouble.scalar.DoubleScalarInterface;
5   
6   /**
7    * <p>
8    * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
9    * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
10   * <p>
11   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 18 okt. 2016 <br>
12   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
13   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
14   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
15   * @param <T> type of the value
16   */
17  public class PersistentStatistic<T extends AbstractDoubleScalarRel<?, T>> implements DoubleScalarInterface
18  {
19  
20      /** Wrapped persistent. */
21      private final Persistent<?, T, ?> persistent;
22  
23      /**
24       * Constructor.
25       * @param persistent
26       */
27      public PersistentStatistic(final Persistent<?, T, ?> persistent)
28      {
29          this.persistent = persistent.copy();
30      }
31  
32      /**
33       * @param alpha confidence level
34       * @return both-side confidence interval
35       */
36      public ConfidenceInterval<T> getConfidenceInterval(final double alpha)
37      {
38          return this.persistent.getConfidenceInterval(alpha);
39      }
40  
41      /**
42       * @param alpha confidence level
43       * @param side side of confidence interval
44       * @return confidence interval
45       */
46      public ConfidenceInterval<T> getConfidenceInterval(final double alpha, final IntervalSide side)
47      {
48          return this.persistent.getConfidenceInterval(alpha, side);
49      }
50      
51      /**
52       * @return sum.
53       */
54      public T getSum()
55      {
56          return this.persistent.getSum();
57      }
58  
59      /**
60       * @return min.
61       */
62      public T getMin()
63      {
64          return this.persistent.getMin();
65      }
66  
67      /**
68       * @return max.
69       */
70      public T getMax()
71      {
72          return this.persistent.getMax();
73      }
74  
75      /**
76       * @return mean.
77       */
78      public T getMean()
79      {
80          return this.persistent.getMean();
81      }
82  
83      /**
84       * @return stDev.
85       */
86      public T getStDev()
87      {
88          return this.persistent.getStDev();
89      }
90  
91      /**
92       * @return variance.
93       */
94      public double getVariance()
95      {
96          return this.persistent.getVariance();
97      }
98  
99      /**
100      * @return n.
101      */
102     public long getN()
103     {
104         return this.persistent.getN();
105     }
106 
107     /** {@inheritDoc} */
108     @Override
109     public double getSI()
110     {
111         return this.persistent.getMean().si;
112     }
113 
114     /** {@inheritDoc} */
115     @Override
116     public double getInUnit()
117     {
118         return this.persistent.getMean().si;
119     }
120 
121 }