jax.random.bernoulli#

jax.random.bernoulli(key, p=0.5, shape=None)[source]#

Sample Bernoulli random values with given shape and mean.

The values are distributed according to the probability mass function:

\[f(k; p) = p^k(1 - p)^{1 - k}\]

where \(k \in \{0, 1\}\) and \(0 \le p \le 1\).

Parameters:
Return type:

Array

Returns:

A random array with boolean dtype and shape given by shape if shape is not None, or else p.shape.