Skip to content

raplan.distributions

RaPlan distributions module.

Distribution

Bases: ABC

Abstract base class for distributions.

cdf

cdf(x: int | float = 1.0) -> float

Cumulative probability density function of this distribution.

Source code in src/raplan/distributions.py
def cdf(self, x: int | float = 1.0) -> float:
    """Cumulative probability density function of this distribution."""
    if x < 0:
        return 0.0
    return self._cdf(x)

sample abstractmethod

sample() -> float

Take a sample of this distribution.

Source code in src/raplan/distributions.py
@abstractmethod
def sample(self) -> float:
    """Take a sample of this distribution."""

Exponential

Bases: Distribution

Exponential distribution.

Attributes:

Name Type Description
lambd int | float

Occasion rate or 1 divided by the desired mean. In scheduling, it should be greater than zero.

cdf

cdf(x: int | float = 1.0) -> float

Cumulative probability density function of this distribution.

Source code in src/raplan/distributions.py
def cdf(self, x: int | float = 1.0) -> float:
    """Cumulative probability density function of this distribution."""
    if x < 0:
        return 0.0
    return self._cdf(x)

LogNormal

Bases: Distribution

Log-normal distribution.

Attributes:

Name Type Description
mu int | float

Mean of the underlying normal distribution. Any value.

sigma int | float

Standard deviation of the underlying normal distribution. Must be >0.

cdf

cdf(x: int | float = 1.0) -> float

Cumulative probability density function of this distribution.

Source code in src/raplan/distributions.py
def cdf(self, x: int | float = 1.0) -> float:
    """Cumulative probability density function of this distribution."""
    if x < 0:
        return 0.0
    return self._cdf(x)

Pareto

Bases: Distribution

Pareto distribution.

Attributes:

Name Type Description
min_x int | float

Minimum x value.

alpha int | float

Shape parameter.

cdf

cdf(x: int | float = 1.0) -> float

Cumulative probability density function of this distribution.

Source code in src/raplan/distributions.py
def cdf(self, x: int | float = 1.0) -> float:
    """Cumulative probability density function of this distribution."""
    if x < 0:
        return 0.0
    return self._cdf(x)

Triangular

Bases: Distribution

Triangular distribution.

Samples are in the range [low, high] and with the specified mode between those bounds. The mode defaults to the midpoint between the two bounds.

Attributes:

Name Type Description
low int | float

Lower bound of the sample range.

high int | float

Upper bound of the sample range.

mode int | float | None

The mode between those two bounds.

cdf

cdf(x: int | float = 1.0) -> float

Cumulative probability density function of this distribution.

Source code in src/raplan/distributions.py
def cdf(self, x: int | float = 1.0) -> float:
    """Cumulative probability density function of this distribution."""
    if x < 0:
        return 0.0
    return self._cdf(x)

Uniform

Bases: Distribution

A uniform distribution.

cdf

cdf(x: int | float = 1.0) -> float

Cumulative probability density function of this distribution.

Source code in src/raplan/distributions.py
def cdf(self, x: int | float = 1.0) -> float:
    """Cumulative probability density function of this distribution."""
    if x < 0:
        return 0.0
    return self._cdf(x)

Weibull

Bases: Distribution

Weibull distribution (2-parameter).

Attributes:

Name Type Description
alpha int | float

Shape parameter.

mtbf int | float

Mean time between failure.

beta property

beta: float

Weibull scale parameter.

cdf

cdf(x: int | float = 1.0) -> float

Cumulative probability density function of this distribution.

Source code in src/raplan/distributions.py
def cdf(self, x: int | float = 1.0) -> float:
    """Cumulative probability density function of this distribution."""
    if x < 0:
        return 0.0
    return self._cdf(x)

compound_probability

compound_probability(
    probabilities: Iterable[float],
) -> float

Compound CDF value of multiple contributions.

Source code in src/raplan/distributions.py
def compound_probability(probabilities: Iterable[float]) -> float:
    """Compound CDF value of multiple contributions."""
    return max(0.0, 1.0 - math.prod(1 - p for p in probabilities))