distributions.FixedDistribution

Fixed distribution implementation.

Usage

Source

distributions.FixedDistribution()

A degenerate distribution that always returns the same fixed value. Useful for constants or deterministic parameters in models.

This class conforms to the Distribution protocol and provides methods to sample a constant value regardless of the number of samples requested.

Methods

Name Description
__init__() Initialize a fixed distribution.
sample() Generate “samples” from the fixed distribution (always the same value).

__init__()

Initialize a fixed distribution.

Usage

Source

__init__(value)
Parameters
value: float
The constant value that will be returned by sampling.

sample()

Generate “samples” from the fixed distribution (always the same value).

Usage

Source

sample(size=None)
Parameters
size: Optional[Union[int, Tuple[int, …]]] = None
The number/shape of samples to generate:
  • If None: returns the fixed value as a float
  • If int: returns a 1-D array filled with the fixed value
  • If tuple of ints: returns an array with that shape filled with the fixed value
Returns
Union[float, NDArray[np.float64]]
The fixed value:
  • A single float when size is None
  • A numpy array filled with the fixed value with shape determined by size parameter