NumpyDirichletDistribution¶
- class probly.representation.distribution.numpy_dirichlet.NumpyDirichletDistribution(alphas: ndarray)[source]¶
Bases:
NumpyAxisProtected[NumpyDirichletDistribution,NumpyDirichletDistribution | np.ndarray | float,NumpyDirichletDistribution,Never,NumpyDirichletDistribution,NDArray[bool],NumpyDirichletDistribution],DirichletDistribution[NumpyCategoricalDistribution]A Dirichlet distribution stored as a numpy array.
Shape: (…, num_classes) The last axis represents the category dimension.
- property T: ShapeResultT¶
The transposed version of the underlying array.
- alphas: np.ndarray¶
- astype(dtype: DTypeLike, order: Order = 'K', casting: Literal['no', 'equiv', 'safe', 'same_kind', 'unsafe'] = 'unsafe', subok: bool = True, copy: bool = True) OpResultT[source]¶
Cast each protected field using ndarray.astype’s casting and layout options.
- property flags: ArrayFlagsLike¶
The flags of the array.
- classmethod from_array(alphas: np.ndarray | list, dtype: DTypeLike | None = None) Self[source]¶
Create a Dirichlet distribution from an array or list.
- property mT: ShapeResultT¶
The transposed version of the underlying array.
- property mean: NumpyCategoricalDistribution¶
Return the mean of the Dirichlet distribution.
- permitted_functions: ClassVar[set[Callable]] = {<function average>, <function mean>, <function sum>}¶
- permitted_ufuncs: ClassVar[dict[np.ufunc, list[str]]] = {<ufunc 'add'>: ['__call__'], <ufunc 'equal'>: ['__call__'], <ufunc 'not_equal'>: ['__call__'], <ufunc 'subtract'>: ['__call__']}¶
- primary_protected_name = 'alphas'¶
- protected_axes = {'alphas': 1}¶
- protected_values(func: Callable | None = None, method: str | None = None) dict[str, NumpyProtectedValue] | None[source]¶
Read effective values, with optional NumPy function or ufunc permissions.
- reshape(*shape: int | tuple[int, ...], order: str = 'C', copy: bool | None = None) ShapeResultT[source]¶
Return a copy with reshaped protected values.
- sample(num_samples: int = 1, rng: Generator | None = None) NumpySample[NumpyCategoricalDistribution][source]¶
Sample from the Dirichlet distribution (NumPy backend).
- property shape: tuple[int, ...]¶
Read the logical shape without collecting fields unless all broadcast.
- transpose(*axes: int | Sequence[int] | None) ShapeResultT[source]¶
Return a transposed version of the NumpySample.
This method implicitly also provides full axis tracking support for - np.moveaxis - np.rollaxis Those functions call out to transpose methods for custom array types.
- Parameters:
axes – The axes to transpose.
- Returns:
A transposed version of the NumpySample.
- type = 'dirichlet'¶