The :mod:`pytensor.tensor.random` module provides random-number drawing functionality
that closely resembles the :mod:`numpy.random` module.
Reference
=========
.. class:: RandomStream()
A helper class that tracks changes in a shared :class:`numpy.random.RandomState`
and behaves like :class:`numpy.random.RandomState` by managing access
to :class:`RandomVariable`\s. For example:
.. testcode:: constructors
from pytensor.tensor.random.utils import RandomStream
rng = RandomStream()
sample = rng.normal(0, 1, size=(2, 2))
.. class:: RandomStateType(Type)
A :class:`Type` for variables that will take :class:`numpy.random.RandomState`
values.
.. function:: random_state_type(name=None)
Return a new :class:`Variable` whose :attr:`Variable.type` is an instance of
:class:`RandomStateType`.
.. class:: RandomVariable(Op)
:class:`Op` that draws random numbers from a :class:`numpy.random.RandomState` object.
This :class:`Op` is parameterized to draw numbers from many possible
distributions.
Distributions
==============
PyTensor can produce :class:`RandomVariable`\s that draw samples from many different statistical distributions, using the following :class:`Op`\s. The :class:`RandomVariable`\s behave similarly to NumPy's *Generalized Universal Functions* (or `gunfunc`): it supports "core" random variable :class:`Op`\s that map distinctly shaped inputs to potentially non-scalar outputs. We document this behavior in the following with `gufunc`-like signatures.