Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/utils/DataUtil.java @ 3076:5642a83420f2
FLYS artifacts: Removed trailing whitespace.
flys-artifacts/trunk@4670 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 15 Jun 2012 09:30:07 +0000 |
parents | 8afd6a9bb244 |
children |
comparison
equal
deleted
inserted
replaced
3075:db9e2bb34707 | 3076:5642a83420f2 |
---|---|
11 } | 11 } |
12 | 12 |
13 public static boolean guessWaterIncreasing(TDoubleArrayList data, float factor) { | 13 public static boolean guessWaterIncreasing(TDoubleArrayList data, float factor) { |
14 int N = data.size(); | 14 int N = data.size(); |
15 if (N < 2) return false; | 15 if (N < 2) return false; |
16 | 16 |
17 int samples = (int)(factor*N) + 1; | 17 int samples = (int)(factor*N) + 1; |
18 | 18 |
19 int up = 0; | 19 int up = 0; |
20 | 20 |
21 Random rand = new Random(); | 21 Random rand = new Random(); |
22 | 22 |
23 for (int i = 0; i < samples; ++i) { | 23 for (int i = 0; i < samples; ++i) { |
24 int pos2 = rand.nextInt(N-1) + 1; | 24 int pos2 = rand.nextInt(N-1) + 1; |
25 int pos1 = rand.nextInt(pos2); | 25 int pos1 = rand.nextInt(pos2); |
26 double w1 = data.getQuick(pos1); | 26 double w1 = data.getQuick(pos1); |
27 double w2 = data.getQuick(pos2); | 27 double w2 = data.getQuick(pos2); |
28 if (w2 > w1) ++up; | 28 if (w2 > w1) ++up; |
29 } | 29 } |
30 | 30 |
31 return up > samples/2; | 31 return up > samples/2; |
32 } | 32 } |
33 } | 33 } |
34 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 34 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |