Roll n_trials, return true if at least one succeeded. n_trials might be not integer. [0, 1]
| 421 | // not integer. |
| 422 | // [0, 1] |
| 423 | bool bernoulli(double n_trials, double trial_prob) |
| 424 | { |
| 425 | if (n_trials <= 0 || trial_prob <= 0) |
| 426 | return false; |
| 427 | return !decimal_chance(pow(1 - trial_prob, n_trials)); |
| 428 | } |
| 429 | |
| 430 | bool one_chance_in(int a_million) |
| 431 | { |
no test coverage detected