API reference
Module
DistributionHazards.DistributionHazards — Module
DistributionHazards.jl — hazard, cumulative hazard, survival, density (and log-scale variants) for any continuous univariate distribution in Distributions.jl, plus expected_cumhazard(d1, d2) via QuadGK.
Distributions.jl already provides pdf, cdf, ccdf, logpdf, logccdf, and quantile. It does not expose hazard, cumulative hazard, or survival as named functions, even though they are trivially defined for any survival distribution. This package fills that gap, plus an iszero(t) guard so ForwardDiff stays stable through 0^shape expressions at t = 0.
Hazard, cumulative hazard, survival, density
DistributionHazards.hazard — Function
hazard(d, t)Hazard h(t) = f(t) / S(t) of a continuous univariate distribution d at analysis time t.
The generic method evaluates exp(logpdf(d, t) - logccdf(d, t)) rather than pdf(d, t) / ccdf(d, t) directly, so the value stays finite at extreme t where both pdf and ccdf underflow to zero. Closed-form specialisations exist for Exponential, Weibull, Rayleigh, Pareto, and Frechet.
DistributionHazards.cumhazard — Function
cumhazard(d, t)Cumulative hazard H(t) = -log S(t). Returns zero at t = 0 to keep ForwardDiff stable through distributions whose logccdf evaluates 0^shape at the boundary (Weibull, Gamma, log-logistic, …).
DistributionHazards.survival — Function
survival(d, t)Survival function S(t) = 1 - F(t), equal to Distributions.ccdf(d, t).
DistributionHazards.density — Function
density(d, t)Probability density f(t) = pdf(d, t).
Log-scale variants
DistributionHazards.log_hazard — Function
log_hazard(d, t)log h(t) = log f(t) - log S(t). Evaluated via logpdf and logccdf so it stays AD-stable on the log scale.
DistributionHazards.log_survival — Function
log_survival(d, t)log S(t) = -H(t). Evaluated as -cumhazard(d, t) so it inherits the t = 0 guard.
DistributionHazards.log_density — Function
log_density(d, t)log f(t) = logpdf(d, t).
Derived helpers
DistributionHazards.expected_cumhazard — Function
expected_cumhazard(d1, d2; atol=1e-10, rtol=1e-8) -> Float64E[H_{d1}(X)] for X ~ d2, computed by adaptive Gauss–Kronrod quadrature over the support of d2.
In branching-process epidemiology, with d1 a contact-interval distribution and d2 an infectious-period distribution, this is the basic reproduction number R₀ in the no-depletion limit.