Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java @ 3565:b136113dad53
FixA: Only evict only one(!) data point as outlier before recalculating the function.
flys-artifacts/trunk@5163 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 31 Jul 2012 16:46:36 +0000 |
parents | 1b9f791937c3 |
children | e727e3ebdf85 |
comparison
equal
deleted
inserted
replaced
3564:e01b9d1bc941 | 3565:b136113dad53 |
---|---|
1 package de.intevation.flys.artifacts.model.fixings; | 1 package de.intevation.flys.artifacts.model.fixings; |
2 | |
3 import de.intevation.flys.artifacts.math.Outlier.IndexedValue; | |
4 import de.intevation.flys.artifacts.math.Outlier.Outliers; | |
5 | 2 |
6 import de.intevation.flys.artifacts.math.Outlier; | 3 import de.intevation.flys.artifacts.math.Outlier; |
7 | 4 |
8 import de.intevation.flys.artifacts.math.fitting.Function; | 5 import de.intevation.flys.artifacts.math.fitting.Function; |
9 | 6 |
155 if (xs.size() < 2) { | 152 if (xs.size() < 2) { |
156 log.warn("Too less points."); | 153 log.warn("Too less points."); |
157 return false; | 154 return false; |
158 } | 155 } |
159 | 156 |
160 List<IndexedValue> inputs = new ArrayList<IndexedValue>(xs.size()); | 157 List<Double> inputs = new ArrayList<Double>(xs.size()); |
161 | 158 |
162 de.intevation.flys.artifacts.math.Function instance = null; | 159 de.intevation.flys.artifacts.math.Function instance = null; |
163 | 160 |
164 LevenbergMarquardtOptimizer lmo = null; | 161 LevenbergMarquardtOptimizer lmo = null; |
165 | 162 |
202 inputs.clear(); | 199 inputs.clear(); |
203 | 200 |
204 for (int i = 0, N = xs.size(); i < N; ++i) { | 201 for (int i = 0, N = xs.size(); i < N; ++i) { |
205 double y = instance.value(xs.getQuick(i)); | 202 double y = instance.value(xs.getQuick(i)); |
206 if (Double.isNaN(y)) { | 203 if (Double.isNaN(y)) { |
207 continue; | 204 y = Double.MAX_VALUE; |
208 } | 205 } |
209 inputs.add(new IndexedValue(i, ys.getQuick(i) - y)); | 206 inputs.add(Double.valueOf(ys.getQuick(i) - y)); |
210 } | 207 } |
211 | 208 |
212 Outliers outliers = Outlier.findOutliers(inputs); | 209 Integer outlier = Outlier.findOutlier(inputs); |
213 | 210 |
214 if (!outliers.hasOutliers()) { | 211 if (outlier == null) { |
215 break; | 212 break; |
216 } | 213 } |
217 | 214 |
218 List<IndexedValue> rem = outliers.getRemoved(); | 215 int idx = outlier.intValue(); |
219 | 216 removed.add( |
220 for (int i = rem.size()-1; i >= 0; --i) { | 217 qwdFactory.create( |
221 int idx = rem.get(i).getIndex(); | 218 xs.getQuick(idx), ys.getQuick(idx))); |
222 removed.add( | 219 xs.remove(idx); |
223 qwdFactory.create( | 220 ys.remove(idx); |
224 xs.getQuick(idx), ys.getQuick(idx))); | |
225 xs.remove(idx); | |
226 ys.remove(idx); | |
227 } | |
228 } | 221 } |
229 | 222 |
230 StandardDeviation stdDev = new StandardDeviation(); | 223 StandardDeviation stdDev = new StandardDeviation(); |
231 | 224 |
232 referenced = new QWD[xs.size()]; | 225 referenced = new QWD[xs.size()]; |