distributions.Uniform

Uniform distribution implementation.

Usage

Source

distributions.Uniform()

A continuous probability distribution where all values in a range have equal probability of being sampled.

This class conforms to the Distribution protocol and provides methods to sample from a uniform distribution between specified low and high values.

Methods

Name Description
__init__() Initialize a uniform distribution.
sample() Generate random samples from the uniform distribution.

__init__()

Initialize a uniform distribution.

Usage

Source

__init__(low, high, random_seed=None)
Parameters
low: float

Lower bound of the distribution range.

high: float

Upper bound of the distribution range.

random_seed: Optional[Union[int, SeedSequence]] = None
A random seed or SeedSequence to reproduce samples. If None, a unique sample sequence is generated.

sample()

Generate random samples from the uniform distribution.

Usage

Source

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