1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.math.stat.descriptive;
17
18 /**
19 * Extends the definition of {@link UnivariateStatistic} with
20 * {@link #increment} and {@link #incrementAll(double[])} methods for adding
21 * values and updating internal state.
22 * <p>
23 * This interface is designed to be used for calculating statistics that can be computed in
24 * one pass through the data without storing the full array of sample values.
25 *
26 * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
27 */
28 public interface StorelessUnivariateStatistic extends UnivariateStatistic {
29
30 /**
31 * Updates the internal state of the statistic to reflect the addition of the new value.
32 * @param d the new value.
33 */
34 void increment(double d);
35
36 /**
37 * Updates the internal state of the statistic to reflect addition of
38 * all values in the values array. Does not clear the statistic first --
39 * i.e., the values are added <strong>incrementally</stong> to the dataset.
40 *
41 * @param values array holding the new values to add
42 * @throws IllegalArgumentException if the array is null
43 */
44 void incrementAll(double[] values);
45
46 /**
47 * Updates the internal state of the statistic to reflect addition of
48 * the values in the designated portion of the values array. Does not
49 * clear the statistic first -- i.e., the values are added
50 * <strong>incrementally</stong> to the dataset.
51 *
52 * @param values array holding the new values to add
53 * @param start the array index of the first value to add
54 * @param length the number of elements to add
55 * @throws IllegalArgumentException if the array is null or the index
56 */
57 void incrementAll(double[] values, int start, int length);
58
59 /**
60 * Returns the current value of the Statistic.
61 * @return value of the statistic, <code>Double.NaN</code> if it
62 * has been cleared or just instantiated.
63 */
64 double getResult();
65
66 /**
67 * Returns the number of values that have been added.
68 * @return the number of values.
69 */
70 long getN();
71
72 /**
73 * Clears the internal state of the Statistic
74 */
75 void clear();
76
77 }