| 74 | } |
| 75 | |
| 76 | int draw(const Dist& d, double u) { |
| 77 | double cum = 0.0; |
| 78 | for (size_t i = 0; i < d.ids.size(); ++i) { |
| 79 | cum += d.p[i]; |
| 80 | if (u < cum) return d.ids[i]; |
| 81 | } |
| 82 | return d.ids.back(); |
| 83 | } |
| 84 | |
| 85 | namespace { |
| 86 | // each penalized token once with its count among the last n of seq |
no test coverage detected