# random – Low-level random numbers#

## Low-level random numbers#

The pytensor.tensor.random module provides random-number drawing functionality that closely resembles the numpy.random module.

pytensor.tensor.random.basic.chisquare(df, size=None, **kwargs)[source]#

Draw samples from a chisquare distribution.

The probability density function for chisquare in terms of the number of degrees of freedom $$k$$ is:

$f(x; k) = \frac{(1/2)^{k/2}}{\Gamma(k/2)} x^{k/2-1} e^{-x/2}$

for $$k > 2$$. $$\Gamma$$ is the gamma function:

$\Gamma(x) = \int_0^{\infty} t^{x-1} e^{-t} \mathrm{d}t$

This variable is obtained by summing the squares $$k$$ independent, standard normally distributed random variables.

### Signature#

() -> ()

param df:

The number $$k$$ of degrees of freedom. Must be positive.

param size:

Sample shape. If the given size is, e.g. (m, n, k) then m * n * k independent, identically distributed random variables are returned. Default is None in which case a single random variable is returned.

pytensor.tensor.random.basic.permutation(x, **kwargs)[source]#

Randomly permute a sequence or a range of values.

### Signature#

(x) -> (x)

param x:

If x is an integer, randomly permute np.arange(x). If x is a sequence, shuffle its elements randomly.