heap_lattice: Mixed-grain reader by Moebius inversion at exclusive replica...

View source: R/detector.R

heap_latticeR Documentation

Mixed-grain reader by Moebius inversion at exclusive replica centers.

Description

Reads the share of an integer-valued sample that was rounded to each of several grains. A class of reports rounded to grain g is a lattice variable with spacing g, so its characteristic function is exactly one at every multiple of 2*pi/g. At a replica center of g that is not a center of any finer grain, that class contributes its full weight while each finer class contributes the Fourier transform of its residue-class distribution modulo g. The Moebius differences of the amplitudes at those exclusive centers are therefore the grain weights. The empirical characteristic function is evaluated directly on the sample with no binning, and the sampling floor 1/n is removed from the squared amplitude.

Usage

heap_lattice(y, grains = c(1, 5, 10, 20), nboot = 0, seed = 20260627)

Arguments

y

integer-valued heaped sample.

grains

candidate grains; must include 1 (e.g. c(1, 5, 10, 20)).

nboot

bootstrap resamples for standard errors; 0 for none.

seed

seed for the bootstrap.

Details

The finer classes' contributions vanish only when the base density is smooth at the scale of the coarsest grain. When it is sharp at that scale they alias into the coarse grain's exclusive centers and the reading is biased, most on the coarsest grain. The regime is set by kappa, the standard deviation of the dequantized base over the coarsest grain. On a known-truth sweep the reader recovers every weight to within about four percent once kappa exceeds roughly three, and recovers the unit share, and hence the heaped fraction, at every kappa tested. Below that the grain split should be read as descriptive rather than as a measurement.

This replaces the reader released in version 1.0.0, which normalized replica amplitudes without inverting. That reader returned an unrounded share that was identically its grain-one weight, so the two quantities it reported separately were the same number, and it was biased on every grain of a known-truth simulation. Results from it are superseded.

Value

A list with grains, weights (the weight on grain 1 is the unit share, so one minus it is the heaped fraction), the exclusive-center amplitudes, n, and when nboot > 0 the boot_se and the resample matrix boot_w.

Examples

set.seed(1)
base <- round(rnorm(4000, 100, 30))
g <- sample(c(1, 5, 10, 20), 4000, replace = TRUE, prob = c(.4, .3, .2, .1))
y <- g * round(base / g)
heap_lattice(y, grains = c(1, 5, 10, 20))

adheaping documentation built on Sept. 18, 2026, 1:06 a.m.