beta#

deeptrack.backend.array_api_compat_ext.torch.random.beta(a: float | Tensor, b: float | Tensor, size: tuple[int, ...] | None = None) Tensor#

Sample from a Beta distribution.

Mirrors numpy.random.beta, including support for tensor parameters and broadcasting. If a and/or b are tensors, the output batch shape follows their broadcasted shape.

Parameters#

a: float | torch.Tensor

First shape parameter (alpha). Can be a scalar or a tensor.

b: float | torch.Tensor

Second shape parameter (beta). Can be a scalar or a tensor.

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

Sample shape prepended to the broadcasted parameter shape. If None, returns samples with the broadcasted parameter shape (scalar if both parameters are scalars).

Returns#

torch.Tensor

Samples drawn from Beta(a, b). Output shape is size + batch_shape, where batch_shape is the broadcasted shape of a and b.

Examples#

>>> import deeptrack.backend.array_api_compat_ext.torch.random as rnd

Scalar parameters:

>>> rnd.beta(2.0, 5.0)
tensor(0.0784)

Tensor parameters (broadcasted):

>>> import torch
>>>
>>> a = torch.tensor([2.0, 3.0])
>>> b = torch.tensor([5.0, 7.0])
>>> rnd.beta(a, b)
tensor([0.2679, 0.2765])

With explicit sample shape:

>>> rnd.beta(a, b, (4,)).shape
torch.Size([4, 2])