| 1 | /// Taken from SMHasher. |
| 2 | |
| 3 | #include "AvalancheTest.h" |
| 4 | |
| 5 | //----------------------------------------------------------------------------- |
| 6 | |
| 7 | double maxBias(std::vector<int> & counts, int reps) |
| 8 | { |
| 9 | double worst = 0; |
| 10 | |
| 11 | for (int i = 0; i < static_cast<int>(counts.size()); i++) |
| 12 | { |
| 13 | double c = static_cast<double>(counts[i]) / static_cast<double>(reps); |
| 14 | |
| 15 | double d = fabs(c * 2 - 1); |
| 16 | |
| 17 | if (d > worst) |
| 18 | { |
| 19 | worst = d; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | return worst; |
| 24 | } |
| 25 | |
| 26 | //----------------------------------------------------------------------------- |
| 27 | |