← Back to all sparks
G

gkwdist

INFRA · APIS
Velocity2.5

Generalized Kumaraswamy Distribution Family

gkwdist keeps finding that its distributions were returning the wrong numbers.

r-packagestatistical-distributionsnumerical-stabilitymlecorrectness-fixes
Current state
The package implements the Generalized Kumaraswamy distribution family and its sub-families. The current release fixes six numerical defects, the most serious being that dgkw() returned zero for every input because internal helpers collided with same-named functions in R's public Rmath.h header. Log-likelihoods for three sub-families were also wrong for data near zero due to clamping instead of working in log space.
Where it's heading
Every release in this window is correctness work with an unchanged public API — critical MLE fixes in 1.1.3, a CRAN timing-test patch in 1.1.4, numerical corrections in 1.1.5. The recurring theme is that analytically correct formulas were being defeated by implementation details: name collisions, sign errors returning negative infinity where positive was required, and clamping thresholds that destroyed precision in the tails. Test infrastructure added in 1.1.2 validates analytical derivatives against numerical differentiation, which is how several of these were caught.
Prediction
Expect further validation-driven fixes rather than new distributions, since the derivative-checking suite added earlier is still surfacing defects in existing routines.

Recent moves

  1. 6d ago

    v1.1.5 — Numerical correctness fixes and componentwise derivative validation

    Six numerical fixes with no API change. That the main density function returned zero for every input where the header collision was active means any analysis built on it produced nothing usable, making this a required upgrade rather than an optional one.

    View source ↗
  2. 2mo ago

    v1.1.4 — CRAN fix: skip timing-based tests on CRAN

    Skips timing-based benchmarks during CRAN checks after loaded CRAN hosts made the performance ratio assertion fail. No functional change; the benchmarks remain for local development.

    View source ↗
  3. 2mo ago

    v1.1.3 — Critical MLE Bug Fixes & Numerical Corrections

    Fixes that directly affected fitted results: a log-likelihood returning negative rather than positive infinity for invalid parameters, which gradient optimizers read as a global minimum and converged to silently. Standard errors for a range of beta values were also wrong.

    View source ↗
  4. 7mo ago

    Adds analytical derivative validation across all sub-families

    C++ source cleanup plus a new suite of 70 tests comparing analytical gradients and Hessians against numerical differentiation across all seven sub-families. The tests matter more than the cleanup — they are the mechanism behind the later fixes.

    View source ↗
  5. 8mo ago

    Refactors the C++ backend around stable log-space utilities

    A backend refactor introducing shared numerically stable utilities for log-space arithmetic and consistent parameter validation across families. The same helpers later caused the header name collision, which is how this refactor connects to the current release.

    View source ↗