W3cubDocs

/TensorFlow 2.4

tf.random.stateless_poisson

Outputs deterministic pseudorandom values from a Poisson distribution.

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.
Args
shape A 1-D integer Tensor or Python array. The shape of the output tensor.
seed A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)
lam Tensor. The rate parameter "lambda" of the Poisson distribution. Shape must match the rightmost dimensions of shape.
dtype Dtype of the samples (int or float dtypes are permissible, as samples are discrete). Default: int32.
name A name for the operation (optional).
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].

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/random/stateless_poisson