NumpyGaussianDistributionSample

class probly.representation.distribution.numpy_gaussian.NumpyGaussianDistributionSample(array: D, sample_axis: int, weights: np.ndarray | None = None)[source]

Bases: GaussianDistributionSample[NumpyGaussianDistribution], NumpySample[NumpyGaussianDistribution]

Sample type for empirical second-order Gaussian distributions.

property T: Self

The transposed version of the underlying array.

array: D
astype(dtype: DTypeLike, order: Order = 'K', casting: Literal['no', 'equiv', 'safe', 'same_kind', 'unsafe'] = 'unsafe', subok: bool = True, copy: bool = True) Self[source]

Cast the stored array while preserving the sample axis and weights.

concat(other: Sample[D]) Self[source]

Append another sample to this sample.

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

Create a copy of the NumpySample.

Returns:

A copy of the NumpySample.

property device: str

The device of the underlying array.

property dtype: dtype

The data type of the underlying array.

property flags: ArrayFlagsLike

The flags of the array.

classmethod from_iterable(samples: Iterable[D], weights: Iterable[float] | None = None, sample_axis: SampleAxis = 'auto', dtype: DTypeLike | None = None) Self[source]

Create an NumpySample from a sequence of samples.

Parameters:
  • samples – The predictions to create the sample from.

  • weights – Optional weights for the samples.

  • sample_axis – The dimension along which samples are organized.

  • dtype – Desired data type of the array.

Returns:

The created NumpySample.

classmethod from_sample(sample: Sample[D], sample_axis: SampleAxis = 'auto', dtype: DTypeLike | None = None) Self[source]

Create a new Sample from an existing Sample.

Parameters:
  • sample – The sample to create the new sample from.

  • sample_axis – The dimension along which samples are organized.

Returns:

The created Sample.

property is_weighted: bool

Return whether the samples are weighted.

property mT: Self

The transposed version of the underlying array.

move_sample_axis(new_sample_axis: int) NumpySample[D][source]

Return a new NumpySample with the sample dimension moved to new_sample_axis.

Parameters:

new_sample_axis – The new sample dimension.

Returns:

A new NumpySample with the sample dimension moved.

property ndim: int

The number of dimensions of the underlying array.

sample_axis: int
sample_mean() D[source]

Compute the mean of the sample.

property sample_size: int

Return the number of samples.

sample_space[source]

alias of NumpyGaussianDistribution

sample_std(ddof: int = 0) D[source]

Compute the standard deviation of the sample.

sample_var(ddof: int = 0) D[source]

Compute the variance of the sample.

property samples: D

Return an iterator over the samples.

property shape: tuple[int, ...]

The shape of the underlying array.

property size: int

The total number of elements in the underlying array.

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

Move the array to a device.

transpose(*axes: int | None) Self[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.

weights: ndarray | None