Samples from a binomial distribution with \(n\) trials and success probability \(p\).
When size = 1 (the default), this is a Bernoulli distribution.
Arguments
- shape
(
integer())
Shape of the result.- size
(
integer(1))
Number of trials.0gives a sample of zeros, likerbinom().- prob
(
numeric(1))
Probability of success on each trial.- dtype
(
NULL|character(1)|DataType)
Numeric type of the sample.NULL(default) uses the default integer type. The number of successes are converted to it, so it must holdsize.
Value
(arrayish)
The sample, of shape shape and data type dtype.
Random State
The draws come from the active random state: the global random state (see
nv_set_seed()), or the random state that with_nv_rng_state() or
local_nv_rng_state() make the default for a scope. They advance it in
place.
See also
Other rng:
local_nv_rng_state(),
nv_normal,
nv_rng_state(),
nv_sample(),
nv_sample_int(),
nv_set_seed(),
nv_uniform
Examples
# Bernoulli samples
with_nv_seed(42L, nv_rbinom(c(2, 3)))
#> AnvlArray
#> 1 0 0
#> 1 1 0
#> [ CPUi32{2,3} ]