Outputs deterministic pseudorandom values from a binomial distribution.
View aliases
Compat aliases for migration
See Migration guide for more details.
tf.random.stateless_binomial(
shape,
seed,
counts,
probs,
output_dtype=tf.dtypes.int32
,
name=None
)
The generated values follow a binomial distribution with specified count and probability of success parameters.
This is a stateless version of tf.random.Generator.binomial
: if run twice
with the same seeds and shapes, it will produce the same pseudorandom numbers.
The output is consistent across multiple runs on the same hardware (and
between CPU and GPU), but may change between versions of TensorFlow or on
non-CPU/GPU hardware.
Example:
counts = [10., 20.]
# Probability of success.
probs = [0.8]
binomial_samples = tf.random.stateless_binomial(
shape=[2], seed=[123, 456], counts=counts, probs=probs)
counts = ... # Shape [3, 1, 2]
probs = ... # Shape [1, 4, 2]
shape = [3, 4, 3, 4, 2]
# Sample shape will be [3, 4, 3, 4, 2]
binomial_samples = tf.random.stateless_binomial(
shape=shape, seed=[123, 456], counts=counts, probs=probs)