01: /*
02: * Copyright 2003-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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
29: UnivariateStatistic {
30:
31: /**
32: * Updates the internal state of the statistic to reflect the addition of the new value.
33: * @param d the new value.
34: */
35: void increment(double d);
36:
37: /**
38: * Updates the internal state of the statistic to reflect addition of
39: * all values in the values array. Does not clear the statistic first --
40: * i.e., the values are added <strong>incrementally</stong> to the dataset.
41: *
42: * @param values array holding the new values to add
43: * @throws IllegalArgumentException if the array is null
44: */
45: void incrementAll(double[] values);
46:
47: /**
48: * Updates the internal state of the statistic to reflect addition of
49: * the values in the designated portion of the values array. Does not
50: * clear the statistic first -- i.e., the values are added
51: * <strong>incrementally</stong> to the dataset.
52: *
53: * @param values array holding the new values to add
54: * @param start the array index of the first value to add
55: * @param length the number of elements to add
56: * @throws IllegalArgumentException if the array is null or the index
57: */
58: void incrementAll(double[] values, int start, int length);
59:
60: /**
61: * Returns the current value of the Statistic.
62: * @return value of the statistic, <code>Double.NaN</code> if it
63: * has been cleared or just instantiated.
64: */
65: double getResult();
66:
67: /**
68: * Returns the number of values that have been added.
69: * @return the number of values.
70: */
71: long getN();
72:
73: /**
74: * Clears the internal state of the Statistic
75: */
76: void clear();
77:
78: }
|