bernoulli#
- class brainstate.random.bernoulli(p=0.5, size=None, key=None, check_valid=True)#
Sample Bernoulli random values with given shape and mean.
- Parameters:
p (float, array_like, optional) – A float or array of floats for the mean of the random variables. Must be broadcast-compatible with
shapeand the values should be within [0, 1]. Default 0.5.size (
int|Sequence[int] |integer|Sequence[integer] |None) – A tuple of nonnegative integers representing the result shape. Must be broadcast-compatible withp.shape. The default (None) produces a result shape equal top.shape.key (
int|Array|ndarray|None) – The key for the random number generator. If not given, the default random number generator is used.
- Returns:
out – A random array with boolean dtype and shape given by
shapeifshapeis not None, or elsep.shape.- Return type:
array_like