NumpyGaussianDistribution

class probly.representation.distribution.numpy_gaussian.NumpyGaussianDistribution(mean: ndarray, var: ndarray)[source]

Bases: NumpyAxisProtected[NumpyGaussianDistribution, NumpyGaussianDistribution | np.ndarray | float, NumpyGaussianDistribution, Never, NumpyGaussianDistribution, NDArray[bool], NumpyGaussianDistribution], GaussianDistribution[ndarray]

Gaussian distribution with array parameters.

property T: ShapeResultT

The transposed version of the underlying array.

allowed_types: ClassVar[tuple[type[np.ndarray] | type[np.generic] | type[float] | type[int], ...]] = (<class 'numpy.ndarray'>, <class 'numpy.generic'>, <class 'float'>, <class 'int'>)
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.

copy(order: Order = 'C') → OwnerT[source]

Return a copy of the array.

property device: str

Device of the array.

property dtype: dtype

Data type of the array.

entropy() → ArrayLike[source]

Compute entropy.

property flags: ArrayFlagsLike

The flags of the array.

property mT: ShapeResultT

The transposed version of the underlying array.

mean: np.ndarray
property ndim: int

Number of dimensions.

permitted_functions = {}
permitted_ufuncs = {}
primary_protected_name = 'mean'
protected_axes = {'mean': 0, 'var': 0}
property protected_shape: tuple[int, ...]

Protected trailing shape of the primary field.

protected_value() → NumpyProtectedValue[source]

Return the primary protected value.

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.

quantile(q: float | list[float] | ndarray) → ndarray[source]

Calculate the quantile function at the given points.

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[ndarray][source]

Draw samples and wrap them in an NumpySample (sample_axis=0).

property shape: tuple[int, ...]

Read the logical shape without collecting fields unless all broadcast.

property size: int

Number of elements in the array.

property std: ndarray

Get the standard deviation.

to_device(device: Any, /, *, stream: Any = None) → Self[source]

Move the array to a device.

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: ClassVar[Literal['gaussian']] = 'gaussian'
validate() → None[source]

Raise if effective fields have insufficient rank or incompatible batches.

Call explicitly, or from __post_init__ to check dataclass construction. Fields owned by initialization (init=False) are excluded.

var: np.ndarray
with_protected_values(values: dict[str, NumpyProtectedValue], func: Callable | None = None) → OwnerT | OpResultT | ShapeResultT | CompResultT | SetResultT[source]

Return a copy with updated protected field values.

Examples using probly.representation.distribution.numpy_gaussian.NumpyGaussianDistribution

Point predictions and first-order distributions

Point predictions and first-order distributions