Statistical Functions for the Delaporte Distribution
Overview
Provides probability mass, distribution, quantile, random-variate generation, and method-of-moments parameter-estimation functions for the Delaporte distribution with parameterization based on Vose (2008) <isbn:9780470512845>. The Delaporte is a discrete probability distribution which can be considered the convolution of a negative binomial distribution with a Poisson distribution. Alternatively, it can be considered a counting distribution with both Poisson and negative binomial components. It has been studied in actuarial science as a frequency distribution which has more variability than the Poisson, but less than the negative binomial.
While there are breaking changes below, the majority of them would not have been encountered in normal practice. Most users should see no change to results, other than increased speed and fewer failures.
Fixed
- **Breaking:** Internal function
log1pnow carries a cubic Taylor term. The prior quadratic form left a truncation error of order beta^3 / 3. For large with very small this reached the sixth significant figure of ordinary probabilities. Results for beta > 1e-4 are bitwise-unchanged. - **Breaking:** Non-finite parameters now return
NaNwith a warning acrossd/p/q/rdelapinstead of clamp-laundered 0s and 1s. - **Breaking:**
ddelap,pdelap,qdelap, andrdelapwith singleton parameters now first attempt to build their PMF and CDF tables using a three-term recurrence relationship derived from the Delaporte distribution's probability generating function. This takes O(K) arithmetic operations instead of O(K^2)log_gamma/expevaluations. Masses whose leading term underflows---roughly + (1+) > 745---are handled by internal rescaling, allowing accuracy to be retained for very large . This is done natively in linear- or log-space as per the call. This may shift results relative to the old "always sum" algorithm at the level of accumulated rounding: one or two ulps for short tables, growing with table length to roughly the 13th significant digit for very long ones. Both parameters extreme enough to risk overflow in the recurrence fall back to the summation algorithm and vector-valued parameters continue to use the per-element path. - **Breaking:**
ddelapandpdelapnow treat arguments below the support the same way base R does.ddelapreturns0(-Infwithlog = TRUE) andpdelapreturns a lower-tail CDF of0and a survival of1. Previously these inputs returnedNaNwith a "NaNs produced" warning. - **Breaking:**
ddelap's internal summand formula subtracted from its running sum before a large canceling pair, lgamma(alpha+i) - lgamma(alpha) (exactly 0 at i = 0), had resolved. When is very small, lgamma(alpha) is itself large, and , when smaller than that intermediate value's rounding unit, was silently discarded before the cancellation completed. This was invisible withlog = FALSE, sinceexp()of the resulting error andexp(0) = 1are both indistinguishable in linear-space double precision at the affected magnitudes. Parenthesizing the canceling pair so it resolves first fixes both the log-space and linear-space summand formulas. Ordinary (non-degenerate) parameters are bitwise-unchanged. - **Breaking:**
ddelapwithlog = TRUEnow accumulates the PMF in log space using a streaming log-sum-exp instead of taking the log of the linear-space result. This is technically breaking as deep-tail log-probabilities which previously returned-Infbecause the linear PMF underflowed below the smallest representable double are now accurate to near full precision. For example,ddelap(2000, 1, 1, 1, log = TRUE)returns approximately -1385.99 instead of-Inf. Hoisting the variables for both log and normal space routines makes them slightly faster than before. - **Breaking:**
pdelapwithlower.tail = FALSEnow computes the upper tail by direct summation of the PMF when doing so is needed to preserve accuracy, instead of 1 - CDF. Survival probabilities near or below machine epsilon previously returned only floating-point rounding noise. For example,pdelap(60, 1, 1, 1, lower.tail = FALSE)returned roughly 3.3e-16 when the true value is roughly 1.18e-18. The algorithms are now accurate to near full double precision. This is technically breaking, but users should see no change outside of the deep tail which was likely not of interest to most. This summation is used only once the survival probability is small enough that the ordinary complement 1 - CDF would lose meaningful precision: below sqrt(EPS) ~ 1.49e-8. Since the summation's remainder-bound safeguard gives it an O(beta^2) worst-case cost, it is reserved for where it is genuinely needed. - **Breaking:**
pdelapwithlog.p = TRUEpreviously computed the linear-space CDF/survival first and tooklog()of the result, so any value that underflowed to exactly 0 in the deep tail silently returned-Infeven though the true log-probability is finite.log.p = TRUEis now computed directly in log space throughout, matching the log-space guaranteeddelap(..., log = TRUE)already provides, and is accurate to near full double precision even where the linear-space value underflows.pdelapderives log-probabilities in the saturated bands---log-CDF values within aboutsqrt(.Machine$double.eps)of 0, and their log-survival mirror---from the opposite, relatively accurate side vialog1p(-exp(.))rather than reporting the accumulation's own rounding noise. On the log scale those values now agree with an independentdnbinom*dpoisconvolution oracle to about1e-13relative. In linear space, the original algorithm was already accurate to an ulp, so linear-scale results are unaffected, as is everything outside the bands. All three computational routes---recurrence table, degenerate-ratio elemental fill, and vector-parameter recycling---apply the same repair. A consequence is thatqdelap/pdelapround trips withlog.p = TRUEare now exact in both tails wherever the input is representable. - **Breaking:**
qdelapfor probabilities within accumulated rounding of 1 combined with highly overdispersed parameters previously ground its lookup-table build indefinitely, as the cumulative sum plateaus below such targets no matter how far it extends. These targets are now resolved from the accurate upper-tail survival table, returning the true finite quantile instantly. For example,qdelap(1 - 1e-12, 5, 5, 7000)now returns7630. Ordinary probabilities are unaffected. - **Breaking:**
qdelapwithlower.tail = FALSEand/orlog.p = TRUEnow searches in the native space of the supplied probabilities instead of transforming them to linear lower-tail space first. The old1 - pflip collapsed survival probabilities below machine epsilon to exactly1, returningInfwhereqpoisresolves a finite quantile, and the oldexp()of log-probabilities collapsed deep log-space targets the same way; near-1 targets were inflated by an ulp, stepping round-tripped quantiles up by one. Upper-tail targets are now searched against a survival table built aspdelap, and log-space targets against log-probability tables accumulated by streaming log-sum-exp. The default (lower.tail = TRUE,log.p = FALSE) path is bitwise-unchanged. Interior search targets carry one-sided tolerances sized to their measured noise sources, in the spirit of base R's64 * EPSfuzz inqpois.c. The vector-parameter path retains base R's fuzz verbatim.
Show all changes in 9.0.0Hide the rest of the changes in 9.0.0
- **Breaking:**
qdelapno longer hangs when passed extreme parameter sets whose quantiles are computationally unreachable. The original explicit-summation algorithm, now used when the recurrence table would overflow, costs O(answer^2). Past 2^15 summation stepsqdelapnow returnsNaNfor the unresolved targets with the warning "quantile too large to compute exactly for these parameter values; NaN returned", as a truncated cumulative sum carries no information about a quantile beyond it. The parameter sets involved generally put the true quantile beyond 2^53, where a count is no longer exactly representable as a double in any case. Targets the partial sum *did* resolve, including the p = 0 and p = 1 boundaries, still return normally. - **Breaking:** The approximate form of
qdelap, which has much less utility now (see documentation), will always generate at least 10,000 variates for pooling. It remains capped at no more than 10M variates. Prior behavior for pathologically tiny means (~1e-12) could have resulted in no variants being generated and an NA return. - **Breaking:** The approximate form of
qdelapnow pre-allocates the result vector at full length first and then assigns theNaN,Inf, 0, or proper value for each category. This ensures that elementiof the output always corresponds to elementiof the input. Previously, the return may have scrambled the "valid" inputs if there were non-valid values in the input. - For x 2^{63}, including +
Inf, the functions no longer convertxto an integer kind which it then overflows. Instead, they return 0 or-Infdirectly. - Zero-length parameters now return zero-length results in
p/d/qdelapper base R. This is not considered breaking as it used to fail with a segfault from Fortran. - Zero-length parameters in
rdelapnow returnNaNs per base R. This is not considered breaking as it used to fail with a segfault from Fortran. qdelapandrdelapwith aNaNscalar parameter previously looped indefinitely while consuming memory. Now they returnNaNwith a warning, matchingpdelap.- Prevented
qdelapfrom overwriting passedpvector within Fortran, preserving the.Callcontract.
Changed
- **Breaking:** Both the exact and approximate versions of
qdelapnow returnNaNwith a warning for probabilities strictly greater than one, following base R convention. The function returnsInfonly for probabilities exactly equal to one. Prior behavior was that all probabilities 1 returnedInf. - **Breaking:**
setDelapThreadsno longer callsomp_set_num_threads, andgetDelapThreadsno longer callsomp_get_max_threads. The thread count is package-local and is passed to each parallelized routine, whosenum_threadsclauses already scope it per region. Process-global OpenMP state is never modified, soDelaporteneither affects nor is affected by the threading of other OpenMP-using packages. On load, the count is seeded from the OpenMP runtime default, which respectsOMP_NUM_THREADSandOMP_THREAD_LIMIT. - As the singleton-parameter CDF build is no longer quadratic, the maximum
qforpdelap's fast path was raised from 2^{14} to 2^{24}, and the interactive confirmation prompt now guards only the genuinely slow routes: vector-valued parameters withqat or above 2^{15}, or anyqat or above 2^{24}. When not interactive,pdelapchecks the new (and undocumented)Delaporte.maxqoption in the local environment and stops if the largest value exceeds the option or warns if it does not. The default value is 2^{15}. - Changing
qdelapto use the lookup table most of the timeexact = TRUEmakes it orders of magnitude faster thanexact = FALSEfor essentially all practical parameter ranges. The only time whereexact = FALSEmay still be worth considering is when the expected table length, K = + + 10(1+) + , exceeds roughly 1.5e7. Beyond that point, the exact path's memory use of ~17 bytes per unit of K begins to exceed the bounded ~330MB/2.5s cost of the Monte Carlo approximation. The table size K depends on the distribution's dispersion, not just its mean. A low mean with a high overdispersion can require as large a table as a much larger, near-Poisson mean. Theexact = FALSEremains unavailable for vector-valued parameters regardless of this threshold, as approximate quantiles cannot be pooled across distinct parameter triplets. qdelapandrdelapwith singleton parameters now size their quantile lookup table from a moment-based estimate and grow it geometrically, replacing element-by-element growth whose copying was O(K^2). The table is built with the identical routine and accumulation order aspdelap, so theqdelap(pdelap(k)) == kround trip is preserved bitwise. They now also locate quantiles in the sorted CDF vector by a binary search instead of a linear scan.MoMdelapnow checks that at least 3 values are passed to it, none of which areNA, otherwise it will error. This is not considered breaking as it used to fail with a different error which propagated from Fortran (missing value where TRUE/FALSE needed). Now it never triggers a Fortran call.- Cleaned
Makevarsfrom unneeded calls to BLAS and LAPACK libraries. - The guidance added to Writing R Extensions in r88406 is better adhered to by storing the package-specific state (the thread count and detected CPU count) in an environment inside the *package* namespace. The environment is no longer created in the user's workspace, and is no longer exported.
- Refactored C and Fortran sources to be more manageable using header files, splitting initialization from active function calls, hardening with explicit "only" lists on the Fortran side, removing unnecessary includes, and using the modern bind(C) interface to call back-and-forth between C and Fortran instead of the older F77 idiom.
- The manual now documents the package's accuracy limits at the representation edges: the context dependence of
lower.tail = FALSEvalues at the level of their accumulated rounding, the +/-1 round-trip shoulder for survival targets within aboutsqrt(.Machine$double.eps)of 1, the linear-space convention (and consequent deep-tail saturation) of vector-parameterqdelap, and the cost profile of deep upper-tail log-scale quantiles at high dispersion. - Updated unit tests and documentation for the changes and fixed a number of spelling and grammar mistakes.
Removed
- **Breaking:** The
sOMPT_Cfunction and entry point was removed, including itsR_RegisterCCallableregistration, as were the.onDetachthread reset and its Fortran backendsOMPT_f. - **Breaking:**
DelaporteEnvis no longer exported.
From inst/NEWS.Rd in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 5 (1 internal)includes a package overview page
- Examples that run
- 100%2 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 92%
- Return-value docs
- 100%
- Help pages citing references
- 20%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 5
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Releases over time
Issues over time
Commits over time
8 development-tooling and community-health practices detected across 5 families in the upstream repository
Checks run against github.com/aadler/delaporte on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
Show all practicesHide 1 practice
Dependencies
Installing Delaporte adds no packages beyond those that come with R.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- 9.0.0Latest
- 8.4.32026-01-09 · diff ↗
- 8.4.2
- RR 4.5.0 released · 2025-04-11
- 8.4.12024-06-17 · diff ↗
- RR 4.4.0 released · 2024-04-24
- 8.4.02024-04-04 · diff ↗
- 8.3.02023-10-02 · diff ↗
- 8.2.02023-08-10 · diff ↗ ·
removed 1 export
pattern:^[[:alpha:]]+added 7 exports
ddelap, pdelap, qdelap, rdelap, MoMdelap, getDelapThreads, setDelapThreads - 8.1.12023-06-20 · diff ↗
- RR 4.3.0 released · 2023-04-21
- 8.1.02023-02-01 · diff ↗
- 8.0.32022-09-06 · diff ↗
- RR 4.2.0 released · 2022-04-22
- 8.0.22022-01-20 · diff ↗
Show 40 earlier eventsHide 40 earlier events
- RR 4.1.0 released · 2021-05-18
- 8.0.12021-01-11 · diff ↗
- 8.0.02021-01-05 · diff ↗
- 7.0.52020-11-10 · diff ↗
- 7.0.32020-06-01 · diff ↗
- RR 4.0.0 released · 2020-04-24
- 7.0.22019-05-17 · diff ↗
- 7.0.12019-04-26 · diff ↗
- RR 3.6.0 released · 2019-04-26
- 7.0.02019-02-12 · diff ↗
- 6.3.02018-11-22 · diff ↗
- 6.2.02018-06-22 · diff ↗
- RR 3.5.0 released · 2018-04-23
- 6.1.02017-08-13 · diff ↗
- RR 3.4.0 released · 2017-04-21
- 6.0.02017-03-31 · diff ↗
- 5.0.12017-03-06 · diff ↗
- 5.0.02017-03-05 · diff ↗
- 4.0.32017-01-31 · diff ↗
- 4.0.02017-01-30 · diff ↗
- 3.0.02016-07-19 · diff ↗
- 2.3.12016-06-17 · diff ↗
- 2.3.02016-06-02 · diff ↗
- RR 3.3.0 released · 2016-05-03
- 2.2-32015-07-01 · diff ↗
- RR 3.2.0 released · 2015-04-16
- 2.2-22014-12-04 · diff ↗
- 2.2-12014-09-24 · diff ↗
- 2.2-02014-07-16 · diff ↗
- RR 3.1.0 released · 2014-04-10
- 2.1-12014-04-08 · diff ↗
- 2.1-02014-04-07 · diff ↗
- 2.0-12014-02-05 · diff ↗
- 2.0-02014-02-05 · diff ↗
- 1.1-02014-01-19 · diff ↗
- 1.0-12013-09-01 · diff ↗
- 1.0-02013-07-10 · diff ↗
- 0.1-22013-04-11 · diff ↗
- 0.1-12013-04-09
- RR 3.0.0 released · 2013-04-03
Package metadata
- First published
- 2013-04-09
- Total releases
- 42 / 13 yrs
- License
- BSD_2_clause + file LICENSE OSI · relicensed from GPL (>= 2) | LGPL (>= 3) in 4.0.0
- Minimum R
- ≥ 3.6.0
- Download size
- 79 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("Delaporte")The package provides a citation file that builds its entry when R runs it. Run citation() to see it.
The repository also keeps a CITATION.cff.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-17, which the citation names so these numbers can be found later. More on citing and the projects behind them.