View source on GitHub |
Outputs deterministic pseudorandom values from a Poisson distribution.
tf.random.stateless_poisson(
shape,
seed,
lam,
dtype=tf.dtypes.int32
,
name=None
)
The generated values follow a Poisson distribution with specified rate parameter.
This is a stateless version of tf.random.poisson
: 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, but may change between
versions of TensorFlow or on non-CPU/GPU hardware.
A slight difference exists in the interpretation of the shape
parameter
between stateless_poisson
and poisson
: in poisson
, the shape
is always
prepended to the shape of lam
; whereas in stateless_poisson
the shape of
lam
must match the trailing dimensions of shape
.
Example:
samples = tf.random.stateless_poisson([10, 2], seed=[12, 34], lam=[5, 15])
# samples has shape [10, 2], where each slice [:, 0] and [:, 1] represents
# the samples drawn from each distribution
samples = tf.random.stateless_poisson([7, 5, 2], seed=[12, 34], lam=[5, 15])
# samples has shape [7, 5, 2], where each slice [:, :, 0] and [:, :, 1]
# represents the 7x5 samples drawn from each of the two distributions
rate = tf.constant([[1.], [3.], [5.]])
samples = tf.random.stateless_poisson([30, 3, 1], seed=[12, 34], lam=rate)
# samples has shape [30, 3, 1], with 30 samples each of 3x1 distributions.
Returns | |
---|---|
samples
|
A Tensor of the specified shape filled with random Poisson values.
For each i, each samples[..., i] is an independent draw from the Poisson
distribution with rate lam[i] .
|