mhn 0.1.2

Mainly a bug-fix release, written for users of 0.1.1; the default method of rmhn() also chooses its sampler by re-derived thresholds (see Seeded draws below and Performance).

0.1.1 returns wrong values without a warning in several places, some of them at ordinary parameter values: the skewness and kurtosis at a large shape (mhn_kurtosis(1000, 1, 0) is -0.627 where the true value is 7.5e-7), the variance for a shape close to 1, the distribution function under a strong negative tilt when the mode or the quantile lies below about 1.5e-8, the logarithm of an upper tail close to one and the quantile of such a tail, and the density, distribution function and quantile for a shape or a tilt within 1.5e-8 of alpha = 1 or gamma = 0 but not equal to it. A few of these came with 0.1.1 itself, and 0.1.0 is right there. The true values quoted below come from independent references: arbitrary-precision computations, or the Gamma and normal laws the distribution approaches in the limit. Each fix carries a regression test at the values that failed.

What changes relative to 0.1.1

Deterministic functions. On the grid of 330 parameter triples described under 0.1.1 below, in the 130 cells with |gamma| / sqrt(beta) at most 10, dmhn(), pmhn(), mhn_mean() and mhn_var() agree with 0.1.1 to twelve significant digits in 128 cells and differ by at most 5.3e-11 relative in the other two; qmhn() at p = 0.001, 0.1, 0.5, 0.9 and 0.999 differs in 13 cells, by at most 5.9e-9; mhn_mode() does not change. mhn_skewness() and mhn_kurtosis() change by up to 2.2e-5 and 2.8e-4 relative, for alpha <= 1/2 at gamma / sqrt(beta) = 10, where 0.1.1 is the inaccurate one (see below). Outside these cells values change by more, and those changes are the fixes listed below.

Seeded draws. For a fixed seed rmhn() returns the draws of 0.1.1 over most of the parameter space wherever it uses the sampler 0.1.1 used. The default method now uses RTDR in parts of the space where 0.1.1 used Sun et al.’s Algorithm 1 or 3 (see Performance), and there its draws follow a different sequence. On the 330-cell grid (200 draws per cell under set.seed(20260903), default method), 300 cells give the same draws and 30 a different sequence: 3 (alpha < 1/2 at a tilt of 1e7) where RTDR itself changed, and 27 where the default method changed sampler (12 with gamma > 0 and alpha > 1 at a tilt up to 2 sqrt(alpha), 15 with gamma < 0 and alpha >= 10). In more detail:

Invalid arguments. dmhn(), pmhn(), qmhn() and rmhn() now treat a parameter outside the parameter space, NA and a zero-length argument as the base R distribution functions do, element by element, where 0.1.1 stopped the whole call; and a factor or a string is an error, where 0.1.1 used it as a number (see Interface). Valid arguments give the values and the draws they gave before.

Bug fixes — moments and mode

Bug fixes — density and normalising constant

Bug fixes — distribution and quantile

Bug fixes — random generation

Behaviour at the edges of the double range

Interface

Performance

Measured on an Apple M4 Max against 0.1.1, as medians of repeated calls:

Documentation

Tests

Benchmark and audit scripts

mhn 0.1.1

Bug-fix and maintenance release.

This release corrects a number of numerical defects reachable from the public API. Most returned a wrong number silently rather than raising an error, and most require parameter values outside the ranges 0.1.0 was tested over. Each fix below carries a regression test at the values that failed.

What changes relative to 0.1.0

Numbers change wherever a defect is fixed, and that includes part of the ordinary parameter range — not only the extremes. Everything below was measured against 0.1.0 as published, over a grid of 330 parameter triples spanning alpha in [0.05, 20], beta in [0.01, 100] and gamma in [-1e6, 1e6].

Deterministic functions. Over the 130 grid cells with |gamma| / sqrt(beta) at most 10, dmhn(), pmhn(), mhn_mean() and mhn_var() agree with 0.1.0 to twelve significant digits in 100 cells and differ in 30. The largest change is 8.2e-6 relative, in mhn_var(); dmhn() and pmhn() move by at most 3.1e-9 and mhn_mean() by 1.6e-7. In every case checked against an independent arbitrary-precision reference the 0.1.1 value is the accurate one — the Lemma 2c variance already cancels measurably at |gamma| / sqrt(beta) = 10. Outside that range the differences are far larger, and are the defects listed below.

rmhn() is not seed-compatible with 0.1.0. For a fixed seed, 163 of the 330 cells return a different sequence of draws; 51 of those are in the ordinary range above. Draws at gamma = 0 are unchanged, since that case is a closed-form transform of rgamma(). There are two reasons a sequence changes, and they matter differently:

Bug fixes — random generation

Bug fixes — density, distribution, quantile and moments

Interface

Performance

Source

Tests

DESCRIPTION

Benchmarks

Examples

mhn 0.1.0

Initial release.

Distribution functions

Random generation

CDF and quantile

Summary statistics

Tests and documentation