Skip to contents

Sample Bernoulli random variables on mlx arrays

Usage

mlx_rand_bernoulli(dim, prob = 0.5, device = mlx_default_device())

Arguments

dim

Integer vector specifying array dimensions (shape).

prob

Probability of a one.

device

Execution target: supply "gpu", "cpu", or an mlx_stream created via mlx_new_stream(). Defaults to the current mlx_default_device() unless noted otherwise (helpers that act on an existing array typically reuse that array's device or stream).

Value

An mlx boolean array.

Examples

mask <- mlx_rand_bernoulli(c(4, 4), prob = 0.3)