Skip to content

feat: add LogisticDistribution and GumbelDistribution — closed-form SIMD via vector_exp #54

Description

@OldCrow

Summary

Add two distributions whose PDF and CDF reduce to one or two vector_exp calls per element — the best SIMD candidates of any missing distribution.

Logistic Distribution

Parametrisation: location μ, scale s > 0.

PDF(x) = exp(-(x-μ)/s) / (s · (1 + exp(-(x-μ)/s))²)
CDF(x) = 1 / (1 + exp(-(x-μ)/s))
log CDF(x) = -log(1 + exp(-(x-μ)/s))  [log-sum-exp stable form]

The batch PDF/CDF paths map directly to a single scalar_add(-μ)scalar_multiply(-1/s)vector_exp → arithmetic pipeline. The existing Laplace SIMD path (fabs + vector_exp) is the closest analogue in the codebase.

  • MLE: closed-form μ̂ = sample median; ŝ estimated via Newton–Raphson score equation
  • Mean = μ, Variance = s²π²/3, Skewness = 0, Kurtosis = 6/5
  • Use cases: logistic regression link function, Bayesian logistic priors, growth modelling (Gompertz limit)

Gumbel Distribution (Type I Extreme Value)

Parametrisation: location μ, scale β > 0. Scipy: gumbel_r.

z       = (x - μ) / β
PDF(x)  = (1/β) · exp(-(z + exp(-z)))
CDF(x)  = exp(-exp(-z))
log PDF = -log(β) - z - exp(-z)   [log-space: log + exp pipeline]

The batch path requires two vector_exp operations and one scalar_add/scalar_multiply pair — well-suited to the existing dispatch infrastructure.

  • MLE: closed-form (Euler-Mascheroni γ correction to sample mean for μ; sample std × π/√6 for β)
  • Mean = μ + γβ (γ ≈ 0.5772), Variance = π²β²/6
  • Use cases: extreme value theory (max of many samples), reliability, hydrology, wind speed modelling
  • Left-skewed variant (Gumbel_l, min-stable): CDF = 1 - exp(-exp(z)); trivial sign flip

Implementation notes

  • Follow src/laplace.cpp as the nearest analogue for the vector_exp pipeline structure
  • Both distributions should implement the full 6-step registration checklist in include/core/distribution_meta.h
  • Dispatch thresholds: set to NEVER in all four kXxx tables until profiled; the vector_exp path suggests thresholds will be comparable to Laplace/Exponential
  • GumbelDistribution should expose a min_stable constructor flag or separate GumbelMinDistribution to cover the left-skewed variant

Relationship to other distributions

  • LogLogistic (see separate issue) delegates to Logistic after log-transformation
  • Generalized Extreme Value (GEV, see separate issue) reduces to Gumbel when shape ξ → 0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions