Skip to contents

Samples from a binomial distribution with \(n\) trials and success probability \(p\). When n = 1 (the default), this is a Bernoulli distribution.

Usage

nv_rbinom(shape, initial_state, n = 1L, prob = 0.5, dtype = "i32")

Arguments

shape

(integer())
Shape.

initial_state

(arrayish)
RNG state (ui64[2]).

n

(integer(1))
Number of trials.

prob

(numeric(1))
Probability of success on each trial.

dtype

(character(1) | tengen::DataType)
Data type.

Value

(list() of arrayish)
List of two elements: the updated RNG state and the sampled values.

Examples

state <- nv_rng_state(42L)
# Bernoulli samples
result <- nv_rbinom(c(2, 3), state)
result[[2]]
#> AnvlArray
#>  0 0 1
#>  0 1 1
#> [ CPUi32{2,3} ]