[#absl-Bernoulli] = xref:absl.adoc[absl]::Bernoulli :relfileprefix: ../ :mrdocs: Produces a random boolean value with probability `p` of being `true`. == Synopsis Declared in `<absl/random/distributions.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<typename URBG> bool Bernoulli( URBG&& urbg, double p); ---- == Description `absl::Bernoulli` produces a random boolean value, with probability `p` (where 0.0 <= p <= 1.0) equaling `true`. Prefer `absl::Bernoulli` to produce boolean values over other alternatives such as comparing an `absl::Uniform()` value to a specific output. See https://en.wikipedia.org/wiki/Bernoulli_distribution Example: absl::BitGen bitgen; ... if (absl::Bernoulli(bitgen, 1.0/3721.0)) { std::cout << "Asteroid field navigation successful."; } == Return Value A random boolean value. == Parameters [cols="1,4"] |=== | Name| Description | *urbg* | The uniform random bit generator. | *p* | The probability (in [0, 1]) of producing `true`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#