~ubuntu-branches/ubuntu/quantal/commons-math/quantal

« back to all changes in this revision

Viewing changes to src/test/java/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2010-04-05 23:33:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100405233302-gpqlceked76nw28a
Tags: 2.1-1
* New upstream release.
* Bump Standards-Version to 3.8.4: no changes needed
* Bump debhelper to >= 7
* Switch to 3.0 (quilt) source format:
  - Remove B-D on quilt
  - Add d/source/format
  - Remove d/README.source

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
6
 * (the "License"); you may not use this file except in compliance with
7
7
 * the License.  You may obtain a copy of the License at
8
 
 * 
 
8
 *
9
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 
 * 
 
10
 *
11
11
 * Unless required by applicable law or agreed to in writing, software
12
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
27
import org.apache.commons.math.util.NumberTransformer;
28
28
 
29
29
/**
30
 
 * @version $Revision: 762087 $ $Date: 2009-04-05 10:20:18 -0400 (Sun, 05 Apr 2009) $
 
30
 * @version $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $
31
31
 */
32
32
public class ListUnivariateImpl extends DescriptiveStatistics implements Serializable {
33
33
 
34
34
    /** Serializable version identifier */
35
35
    private static final long serialVersionUID = -8837442489133392138L;
36
 
    
 
36
 
37
37
    /**
38
38
     * Holds a reference to a list - GENERICs are going to make
39
39
     * our lives easier here as we could only accept List<Number>
49
49
    public ListUnivariateImpl(){
50
50
        this(new ArrayList<Object>());
51
51
    }
52
 
    
 
52
 
53
53
    /**
54
54
     * Construct a ListUnivariate with a specific List.
55
55
     * @param list The list that will back this DescriptiveStatistics
57
57
    public ListUnivariateImpl(List<Object> list) {
58
58
        this(list, new DefaultTransformer());
59
59
    }
60
 
    
 
60
 
61
61
    /**
62
62
     * Construct a ListUnivariate with a specific List.
63
63
     * @param list The list that will back this DescriptiveStatistics
109
109
            calcIndex = (list.size() - windowSize) + index;
110
110
        }
111
111
 
112
 
        
 
112
 
113
113
        try {
114
114
            value = transformer.transform(list.get(calcIndex));
115
115
        } catch (MathException e) {
116
116
            e.printStackTrace();
117
117
        }
118
 
        
 
118
 
119
119
        return value;
120
120
    }
121
121
 
141
141
    public void addValue(double v) {
142
142
        list.add(Double.valueOf(v));
143
143
    }
144
 
    
 
144
 
145
145
    /**
146
 
     * Adds an object to this list. 
 
146
     * Adds an object to this list.
147
147
     * @param o Object to add to the list
148
148
     */
149
149
    public void addObject(Object o) {
159
159
    public void clear() {
160
160
        list.clear();
161
161
    }
162
 
    
 
162
 
163
163
    /**
164
164
     * Apply the given statistic to this univariate collection.
165
165
     * @param stat the statistic to apply
174
174
        }
175
175
        return Double.NaN;
176
176
    }
177
 
    
 
177
 
178
178
    /**
179
179
     * Access the number transformer.
180
180
     * @return the number transformer.
190
190
    public void setTransformer(NumberTransformer transformer) {
191
191
        this.transformer = transformer;
192
192
    }
193
 
    
 
193
 
194
194
    /** {@inheritDoc} */
195
195
    @Override
196
196
    public synchronized void setWindowSize(int windowSize) {
197
197
        this.windowSize = windowSize;
198
 
        //Discard elements from the front of the list if the windowSize is less than 
 
198
        //Discard elements from the front of the list if the windowSize is less than
199
199
        // the size of the list.
200
200
        int extra = list.size() - windowSize;
201
201
        for (int i = 0; i < extra; i++) {
209
209
        return windowSize;
210
210
    }
211
211
 
212
 
}
 
 
b'\\ No newline at end of file'
 
212
}