probly.representation.distribution.array_dirichlet

Numpy-based distribution representation.

Classes

ArrayDirichlet([alphas])

A Dirichlet distribution stored as a numpy array.

class probly.representation.distribution.array_dirichlet.ArrayDirichlet(alphas=<property object>)[source]

Bases: DirichletDistribution, NDArrayOperatorsMixin

A Dirichlet distribution stored as a numpy array.

Shape: (…, num_classes) The last axis represents the category dimension.

Parameters:

alphas (ndarray)

classmethod from_array(alphas, dtype=None)[source]

Create a Dirichlet distribution from an array or list.

Parameters:
  • alphas (np.ndarray | list)

  • dtype (DTypeLike)

Return type:

Self

copy()[source]

Create a copy of the distribution.

Return type:

Self

sample(num_samples=1, rng=None)[source]

Sample from the Dirichlet distribution (NumPy backend).

Parameters:
Return type:

ArraySample

to_device(device)[source]

Move the underlying array to the specified device.

Parameters:

device (Literal['cpu'])

Return type:

Self

property T: Self

The transposed version of the distribution.

alphas: ndarray
property device: str

The device of the underlying array.

property dtype: DTypeLike

The data type of the underlying array.

property entropy: float

Compute the entropy of the Dirichlet distribution.

property ndim: int

Number of batch dimensions (excluding category axis).

property shape: tuple[int, ...]

Batch shape (excluding category axis).

property size: int

The total number of distributions.

type: Literal['dirichlet'] = 'dirichlet'