std::bernoulli_distribution, simplified https://en.cppreference.com/w/cpp/numeric/random/bernoulli_distribution
| 71 | // std::bernoulli_distribution, simplified |
| 72 | // https://en.cppreference.com/w/cpp/numeric/random/bernoulli_distribution |
| 73 | struct bernoulli_distribution { |
| 74 | const double p; |
| 75 | |
| 76 | explicit bernoulli_distribution(double p = 0.5) : p(p) {} |
| 77 | |
| 78 | template <class Rng> |
| 79 | bool operator()(Rng& rng) { |
| 80 | return detail::generate_canonical<double>(rng) < p; |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | } // namespace random |
| 85 | } // namespace arrow |