pub struct Pert { /* private fields */ }Expand description
PERT distribution (Program Evaluation and Review Technique).
A modified Beta distribution defined by three points: optimistic (min), most likely (mode), and pessimistic (max).
§Mathematical Definition
Shape parameters (with λ = 4):
α = 1 + λ · (mode − min) / (max − min)
β = 1 + λ · (max − mode) / (max − min)The underlying variable Y = (X − min)/(max − min) follows Beta(α, β).
- Mean: (min + λ·mode + max) / (λ + 2) = (min + 4·mode + max) / 6
- Std Dev (simplified): (max − min) / (λ + 2) = (max − min) / 6
§Exact vs Simplified Variance
The simplified variance ((max−min)/6)² is an approximation. The exact
variance uses the Beta distribution formula:
Var = α·β / ((α+β)²·(α+β+1)) × (max−min)²The simplified formula is exact when the distribution is symmetric (mode = midpoint) and becomes less accurate as skewness increases.
Reference: Malcolm et al. (1959), “Application of a Technique for Research and Development Program Evaluation”, Operations Research 7(5).
Implementations§
Source§impl Pert
impl Pert
Sourcepub fn new(min: f64, mode: f64, max: f64) -> Result<Self, DistributionError>
pub fn new(min: f64, mode: f64, max: f64) -> Result<Self, DistributionError>
Creates a standard PERT distribution (λ = 4).
§Errors
Returns Err if min >= max or mode is outside [min, max].
Sourcepub fn with_shape(
min: f64,
mode: f64,
max: f64,
lambda: f64,
) -> Result<Self, DistributionError>
pub fn with_shape( min: f64, mode: f64, max: f64, lambda: f64, ) -> Result<Self, DistributionError>
Creates a modified PERT distribution with custom shape parameter λ.
λ controls the weight of the mode:
- λ = 4: standard PERT
- λ > 4: tighter distribution (more peaked)
- λ < 4: flatter distribution (less peaked)
§Errors
Returns Err if parameters are invalid.
pub fn min(&self) -> f64
pub fn mode(&self) -> f64
pub fn max(&self) -> f64
pub fn alpha(&self) -> f64
pub fn beta_param(&self) -> f64
Sourcepub fn mean(&self) -> f64
pub fn mean(&self) -> f64
Mean = (min + 4·mode + max) / 6 for standard PERT (λ=4).
General: (min + λ·mode + max) / (λ + 2).
Sourcepub fn variance(&self) -> f64
pub fn variance(&self) -> f64
Exact variance using Beta distribution formula.
Var = α·β / ((α+β)²·(α+β+1)) × (max−min)²Sourcepub fn cdf(&self, x: f64) -> f64
pub fn cdf(&self, x: f64) -> f64
CDF via regularized incomplete beta function approximation.
Uses a numerical approximation of the regularized incomplete beta function I_x(α, β).
Sourcepub fn quantile_approx(&self, p: f64) -> Option<f64>
pub fn quantile_approx(&self, p: f64) -> Option<f64>
Approximate quantile using normal approximation.
Uses μ + σ·Φ⁻¹(p) with the exact PERT mean and std dev.
This is an approximation; accuracy decreases for highly skewed PERTs.
Returns None if p is outside (0, 1).