[#absl-Bernoulli]
= xref:absl.adoc[absl]::Bernoulli
:relfileprefix: ../
:mrdocs:

Produces a random boolean value with probability `p` of being `true`&period;

== Synopsis

Declared in `&lt;absl&sol;random&sol;distributions&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename URBG&gt;
bool
Bernoulli(
    URBG&& urbg,
    double p);
----

== Description

`absl&colon;&colon;Bernoulli` produces a random boolean value, with probability `p` (where 0&period;0 &lt;&equals; p &lt;&equals; 1&period;0) equaling `true`&period;

Prefer `absl&colon;&colon;Bernoulli` to produce boolean values over other alternatives such as comparing an `absl&colon;&colon;Uniform()` value to a specific output&period;

See https&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Bernoulli&lowbar;distribution

Example&colon;

absl&colon;&colon;BitGen bitgen&semi; &period;&period;&period; if (absl&colon;&colon;Bernoulli(bitgen, 1&period;0&sol;3721&period;0)) &lcub; std&colon;&colon;cout &lt;&lt; &quot;Asteroid field navigation successful&period;&quot;&semi; &rcub;

== Return Value

A random boolean value&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *urbg*
| The uniform random bit generator&period;
| *p*
| The probability (in &lsqb;0, 1&rsqb;) of producing `true`&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
