Skip to main content

prefect.utilities.math

Functions

poisson_interval

Generates an “inter-arrival time” for a Poisson process. Draws a random variable from an exponential distribution using the inverse-CDF method. Can optionally be passed a lower and upper bound between (0, 1] to clamp the potential output values.

exponential_cdf

lower_clamp_multiple

Computes a lower clamp multiple that can be used to bound a random variate drawn from an exponential distribution. Given an upper clamp multiple k (and corresponding upper bound k * average_interval), this function computes a lower clamp multiple c (corresponding to a lower bound c * average_interval) where the probability mass between the lower bound and the median is equal to the probability mass between the median and the upper bound.

clamped_poisson_interval

Bounds Poisson “inter-arrival times” to a range defined by the clamping factor. The upper bound for this random variate is: average_interval * (1 + clamping_factor). A lower bound is picked so that the average interval remains approximately fixed.

bounded_poisson_interval

Bounds Poisson “inter-arrival times” to a range. Unlike clamped_poisson_interval this does not take a target average interval. Instead, the interval is predetermined and the average is calculated as their midpoint. This allows Poisson intervals to be used in cases where a lower bound must be enforced.