Samples from a binomial distribution with \(n\) trials and success probability \(p\).
When n = 1 (the default), this is a Bernoulli distribution.
Arguments
- shape
(
integer())
Shape.- initial_state
(
tensorish)
RNG state (ui64[2]).- n
(
integer(1))
Number of trials.- prob
(
numeric(1))
Probability of success on each trial.- dtype
(
character(1)|stablehlo::TensorDataType)
Data type.
See also
Other rng:
nv_rdunif(),
nv_rng_state(),
nv_rnorm(),
nv_runif()
Examples
jit_eval({
state <- nv_rng_state(42L)
# Bernoulli samples
result <- nv_rbinom(c(2, 3), state)
result[[2]]
})
#> AnvilTensor
#> 0 0 1
#> 0 1 1
#> [ CPUi32{2,3} ]