distributions.Exponential

Exponential distribution implementation.

Usage

Source

distributions.Exponential()

A probability distribution that models the time between events in a Poisson process, where events occur continuously and independently at a constant average rate.

This class conforms to the Distribution protocol and provides methods to sample from an exponential distribution with a specified mean.

Methods

Name Description
__init__() Initialize an exponential distribution.
sample() Generate random samples from the exponential distribution.

__init__()

Initialize an exponential distribution.

Usage

Source

__init__(mean, random_seed=None)
Parameters
mean: float

The mean of the exponential distribution. Must be positive.

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 exponential 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 exponential distribution:
  • A single float when size is None
  • A numpy array of floats with shape determined by size parameter