uniform#

deeptrack.backend.array_api_compat_ext.torch.random.uniform(low: float | Tensor, high: float | Tensor, size: tuple[int, ...] | None = None) Tensor#

Sample from a uniform distribution on [low, high).

Mirrors numpy.random.uniform, including support for tensor parameters and broadcasting.

Parameters#

low: float | torch.Tensor

Lower bound.

high: float | torch.Tensor

Upper bound.

size: tuple[int, …] | None, optional

Sample shape. If None, returns a scalar or broadcasted tensor.

Returns#

torch.Tensor

Samples drawn uniformly from [low, high). Output shape is size + batch_shape, where batch_shape is the broadcasted shape of low and high.

Examples#

>>> import deeptrack.backend.array_api_compat_ext.torch.random as rnd
>>> rnd.uniform(0.0, 1.0)
tensor(0.5488)
>>> rnd.uniform(0.0, 1.0, (2, 3)).shape
torch.Size([2, 3])