13.2 Categorical sampling: inverse CDF, Gumbel-max, alias method
The first language model in AI Engineering, the byte bigram, samples text with three lines buried inside BigramLM.sample: a numpy generator, a cumulative sum, a search. Later models need sampling in places those lines cannot serve. word2vec draws millions of negative words from a 50 000-word distribution, and a cumulative sum per draw is 50 000 additions each time. BERT’s masking and the bootstrap need many small draws with a known generator position. The inference sampler must return the same token as the Rust engine for the same seed, which only works if the last step, uniform to id, is pinned down to the comparison (step 11 of spec/sampling.md). And the load generator needs request arrival times that look like real traffic.
Concepts from other sections (11)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Pure function: a function whose output depends only on its inputs and which mutates nothing. Read more: Chapter 4: Coding and Design Patterns in Software Engineering
- Cumulative distribution function (CDF): , defined for every random variable, discrete or continuous; it rises from 0 to 1, and for a continuous variable its derivative is the density. Read more: Chapter 13: Probability and Statistics
- PCG32: an LCG whose output is a permutation (xorshift, then a state-chosen rotation) of the old state. Read more: 12.3 Modular arithmetic, hashing, and PCG32 in Python
- Random variable: a number assigned to each outcome of a random experiment; a discrete one is a table of values and probabilities. Read more: 13.1 Random variables, expectation, variance, and normal draws by Box-Muller
- Op order: the fixed sequence of random draws that makes masking reproducible across implementations. Read more: 12.2 BERT: the bidirectional encoder and masked language modeling in AI Engineering
- Binary search: a search that keeps an interval known to contain the answer and halves it with one comparison per step, taking steps; it needs a monotonic predicate, not necessarily a sorted array. Read more: Chapter 5: Binary search in Programming and Algorithms
- Variance: the expected squared distance from the mean; its square root is the standard deviation. Read more: 13.1 Random variables, expectation, variance, and normal draws by Box-Muller
- logits: unnormalized log-scores that softmax turns into probabilities; here the table stores . Read more: 6.1 Byte bigram: counts, logits, safetensors v0 in AI Engineering
- tie rule: the fixed backtrace preference (diagonal, deletion, insertion) that makes the S, D, I split deterministic. Read more: 15.5 Multimodal eval metrics: WER, CER, VQA, captions, zero-shot in AI Engineering
- Fully masked row: a row of all , defined to give softmax zeros and LSE . Read more: 15.2 Stable numerics: logsumexp, softmax, and compensated sums
- speculative decoding: drafting several tokens cheaply and verifying them in one target-model pass, preserving the output distribution. Read more: Chapter 20: Inference Engines and GPU Deployment in AI Engineering
This section turns uniforms into draws three exact ways, each with a different cost, and makes each one a pure function of its uniforms. Along the way it derives the exponential distribution’s inverse CDF and uses it to generate Poisson arrivals. No code from earlier sections is required, but the samplers read uniforms from the PCG32 generator of Modular arithmetic, hashing, and PCG32, build on the random variables and CDFs of Random variables, expectation, variance, and normal draws, and use the logs of Exponents, logs, and units of information.
The reference implementation is course/solutions/python/tinyllm/prob/sampling.py, with its contract in sampling.pyi. The sampler’s op order is fixed by spec/sampling.md and the generator by spec/pcg32.md.
Learning objectives
- Sample a categorical distribution by inverse CDF with the strict comparison and the rounding fallback that keep zero-probability ids out.
- Prove that Gumbel-max samples exactly, and implement it with masks and ties handled.
- Build an alias table with Vose’s algorithm and draw from it in using one uniform.
- Generate Poisson arrivals from exponential gaps using a numerically accurate inverse CDF.
- Choose among the three samplers by the shape of the workload.
Notation
Section titled “Notation”| Symbol | Meaning | Type / shape |
|---|---|---|
| a categorical distribution: , | float64[n] | |
| the cumulative distribution (CDF); | float64[n] | |
| , | a uniform random variable on , and one draw of it | float |
| a logit: , | float64[n] | |
| a standard Gumbel random variable | float | |
| , | the alias table: column keeps with probability , else gives | float64[n], int64[n] |
| a rate: events per unit time | float | |
| an exponential waiting time, | float |
Randomness comes from outside
Section titled “Randomness comes from outside”None of the functions in this section creates a generator. They take a uniform , or an rng with a uniform() method (the PCG32, which turns two 32-bit draws into one float64 in ). So each is a plain function from uniforms to outcomes: the same uniforms give the same outcomes in every language, and a test can feed chosen uniforms to check edge cases that a real generator would hit once in draws.
The inverse CDF
Section titled “The inverse CDF”The simplest exact sampler lays the probabilities end to end on : id owns the interval , whose length is . Draw and return the id whose interval contains it, the first with . Then
Two details decide correctness. The first is that the comparison is strict: an id with owns the empty interval , and with instead, would return id 0 even when . The second is floating point: ten additions of give , so the largest uniform, , is not below any running sum. Then the answer is the last id with , never simply the last id. The walk costs per draw; binary search over a stored makes it .
The same idea works for any increasing continuous CDF : if is uniform then has . The exponential distribution has , so
Write it with log1p(-u), which is accurate when is tiny, and note gives , never . (Using is the same distribution, since is uniform too, but a different schedule from the same seed, and breaks it.)
That continuous version gives you a model of traffic almost for free. Requests that arrive independently at an average rate have independent gaps. Adding gaps until the time passes the horizon gives the arrival times on ; their count is Poisson with mean and variance . This is the open-loop schedule the load generator replays against the gateway.
Gumbel-max
Section titled “Gumbel-max”The inverse CDF needs normalized probabilities and a running sum. A language model produces logits, and a GPU would rather not run a sequential sum. Gumbel-max avoids both. Draw independent and return . The Gumbel CDF is , with density . Id wins when and every other :
Substitute (): the integral is with , so .
Three consequences follow. The logits need no normalization (a constant shifts every sum equally). A masked logit stays and never wins. And there is no running sum, so every id is processed independently, which is why GPU samplers use this form. The price is uniforms per draw. The sign matters too: is the Gumbel of the minimum, and with it the argmax samples the wrong distribution.
The alias method
Section titled “The alias method”Gumbel-max and the inverse CDF both cost per draw. When you draw millions of times from one fixed distribution, as word2vec does, you want to pay once and per draw. The alias method does exactly that.
Scale the probabilities by , so they average 1, and picture columns of height 1. A column whose scaled mass is below 1 is topped up from a column above 1, and records whom it borrowed from. Vose’s algorithm does this in one pass: keep a list of “small” ids (scaled mass ) and “large” ids (); repeatedly pop one small and one large , set to ‘s mass and , and give the mass it has left, , which goes back to the small or large list. Each step finishes one column, so it ends after at most steps. Whatever remains is a whole column () up to rounding. Column then holds of id and of id , so
A draw picks a column uniformly and flips a biased coin. One uniform does both: , column , coin , which is uniform on and independent of . Keep the column when (strict again: a column with is never kept, even at ). Building costs once; every draw costs whatever is.
Choosing a sampler
Section titled “Choosing a sampler”Each method fits a different workload. Use the inverse CDF for one draw from a distribution that changes every time (the sampler’s next token), and wherever the spec fixes the op order. Use the alias method for many draws from one fixed distribution (negatives from a unigram table). Use Gumbel-max when you want no normalization and a vectorized draw; it is also the root of Gumbel-top-, which draws ids without replacement by keeping the largest .
Working it by hand
Section titled “Working it by hand”Take , five ids, and run each method on it.
Inverse CDF. The running sums are . Id 4 owns , which is empty. Five uniforms land as follows.
| first with | id | |
|---|---|---|
| 0.05 | 0 | |
| 0.10 | is false; | 1 |
| 0.25 | 1 | |
| 0.35 | 2 | |
| 0.99 | 3 |
Alias table (Vose). Scaled mass . Small (below 1): . Large: . Popping from the end of each list gives these steps.
| step | small | large | set | keeps | goes to |
|---|---|---|---|---|---|
| 1 | 4 () | 3 () | , | large | |
| 2 | 0 () | 3 () | , | small | |
| 3 | 3 () | 2 () | , | large | |
| end | ids 1, 2 left in large: |
So , . Check id 3: its own column keeps 0.5, column 0 gives it , column 4 gives it ; . Id 2: .
A draw with : , column 0, coin , so the alias: id 3. With : column 0, coin : id 0. With : column 4, coin : id 3.
Gumbel-max. Logits . Uniforms give noise . Sums: . The argmax is id 0, the least likely id, because its uniform was lucky; that happens with probability exactly 0.1. Four equal uniforms add equal noise and leave the argmax of : id 3.
Poisson arrivals. Rate , horizon 2, uniforms . Gaps : , , . Times: 0.3466, 1.0397, then 2.1910, which is past the horizon: two arrivals, three uniforms used.
These numbers are the first four test cases a correct implementation must reproduce.
Designing the interface
Section titled “Designing the interface”The module exposes four functions for the samplers, one class for the alias table, and two functions for arrivals:
def sample_categorical(probs: ArrayLike, u: float) -> int # first i with u < F_idef gumbel_noise(u: ArrayLike) -> NDArray # -log(-log u), u in (0, 1)def gumbel_max(logits: ArrayLike, gumbels: ArrayLike) -> int # ties to the lowest idclass AliasTable: prob: NDArray # float64 [n] alias: NDArray # int64 [n] def __init__(self, probs: ArrayLike) -> None def __len__(self) -> int def sample(self, rng: UniformSource, n: int) -> NDArray # one rng.uniform() per drawdef exponential_icdf(u: float, rate: float) -> float # -log1p(-u) / ratedef poisson_arrivals(rate: float, horizon: float, rng: UniformSource) -> NDArrayUniformSource is anything with uniform() -> float: the PCG32, or a script of fixed values when checking edge cases. probs must be 1-D, finite, non-negative, and sum to 1 within ; anything else is a ValueError, as is .
Building it step by step
Section titled “Building it step by step”Seven decisions produce the whole implementation.
- Randomness is an argument. Every function takes uniforms (or an
rngwithuniform()) and never builds its own generator. That makes each a pure function, so fixed uniforms test the edges and the same seed gives the same draws in every port. - Validate once, with an exact sum. All samplers share one check: 1-D, non-empty, finite, non-negative, summing to 1. The sum uses
math.fsum(exactly rounded) and a tolerance that grows with , because a long probability vector accumulates rounding of order in whatever produced it. - Inverse CDF is a running sum with a strict comparison. Return the first with . Strict gives a id the empty interval. If the loop ends (rounding left ), return the last id with , not the last id.
- Gumbel-max is argmax of logits plus noise. The noise is with strictly inside (both ends make an infinite noise).
np.argmaxreturns the first maximum, which is the lowest-id tie rule, and masks for free. A row that is all has nothing to sample and must raise rather than return 0. - Vose builds the alias table in one pass. Scale by , split into small () and large (), pair one of each until a list empties, and give the donor . Anything left over is a full column up to rounding, so its
probis set to 1, which also ensures a leftover column never falls through to an alias. - One uniform per alias draw. , column , coin , keep when the coin is strictly below
prob. Clamp the column to so a product that rounds up to cannot index past the end. - Arrivals are cumulative exponential gaps. ; stop at the first and do not keep it, so the result lies in .
The validator and the inverse CDF come first:
def _check_probs(probs: ArrayLike) -> NDArray: p = np.asarray(probs, dtype=np.float64) if p.ndim != 1 or p.size == 0: raise ValueError(f"probs must be a non-empty 1-D array, got shape {p.shape}") if not np.isfinite(p).all(): raise ValueError("probs must be finite") if (p < 0).any(): raise ValueError(f"probs must be non-negative, got min {p.min()}") total = math.fsum(p.tolist()) # exactly rounded: the check itself adds no error if abs(total - 1.0) > 1e-9 * p.size + 1e-12: # tolerance grows with n raise ValueError(f"probs must sum to 1, got {total!r}") return p
def sample_categorical(probs: ArrayLike, u: float) -> int: p = _check_probs(probs) if not 0.0 <= u < 1.0: raise ValueError(f"u must lie in [0, 1), got {u!r}") c = 0.0 for i, pi in enumerate(p.tolist()): c += pi # F_i, accumulated in spec order if u < c: # strict: id i owns [F_{i-1}, F_i) return i # Rounding left the running sum at or below u: the last id that can occur. return int(np.flatnonzero(p > 0)[-1])The running sum is a plain left-to-right += on purpose: spec/sampling.md fixes this op order so the Rust engine reaches the same bit for bit. On the hand example’s , is false and is true, so id 1.
Gumbel-max is two short functions, with the care concentrated in the argument checks:
def gumbel_noise(u: ArrayLike) -> NDArray: a = np.asarray(u, dtype=np.float64) if not ((a > 0.0) & (a < 1.0)).all(): # u = 0 or 1 gives infinite noise raise ValueError("gumbel_noise needs every u in the open interval (0, 1)") return -np.log(-np.log(a)) # the max-Gumbel; log(-log u) is the min-Gumbel
def gumbel_max(logits: ArrayLike, gumbels: ArrayLike) -> int: z = np.asarray(logits, dtype=np.float64) g = np.asarray(gumbels, dtype=np.float64) if z.ndim != 1 or z.size == 0 or g.shape != z.shape: raise ValueError(...) # message elided if np.isnan(z).any() or (z == np.inf).any(): raise ValueError("logits must not be NaN or +inf") if (z == -np.inf).all(): raise ValueError("every logit is -inf: there is nothing to sample") # -inf + g stays -inf, so a masked id never wins; argmax takes the first maximum. return int(np.argmax(z + g))The alias table builds with Vose’s two worklists and samples with one uniform per draw:
class AliasTable: def __init__(self, probs: ArrayLike) -> None: p = _check_probs(probs) n = p.size scaled = (p * n).tolist() # mean 1: a column holds exactly one unit of mass self.prob = np.zeros(n, dtype=np.float64) self.alias = np.arange(n, dtype=np.int64) small = [i for i in range(n) if scaled[i] < 1.0] large = [i for i in range(n) if scaled[i] >= 1.0] while small and large: s, g = small.pop(), large.pop() # Column s keeps its own mass and is topped up from g. self.prob[s] = scaled[s] self.alias[s] = g scaled[g] = (scaled[g] + scaled[s]) - 1.0 # g gave away 1 - m_s (small if scaled[g] < 1.0 else large).append(g) # What is left holds one unit each up to rounding: keep the column whole. for i in large + small: self.prob[i] = 1.0
def sample(self, rng: UniformSource, n: int) -> NDArray: if n < 0: raise ValueError(f"n must be >= 0, got {n}") k = len(self) # Exactly n uniforms, in order: the generator's position after the call is known. u = np.fromiter((rng.uniform() for _ in range(n)), dtype=np.float64, count=n) x = u * k i = np.minimum(np.floor(x).astype(np.int64), k - 1) # column; clamp guards rounding f = x - i # coin: uniform on [0, 1), independent of i return np.where(f < self.prob[i], i, self.alias[i]).astype(np.int64)Tracing the hand example: small and large , so the first pop pair is , then , then , exactly the table above; ids 1 and 2 remain in large and get prob = 1. A small id left over when large empties (its mass is from rounding) also gets 1, so it is never redirected to a meaningless alias. The parenthesization (scaled[g] + scaled[s]) - 1.0 is fixed so every port computes the same leftover.
Finally, the exponential inverse CDF and the arrival process built from it:
def exponential_icdf(u: float, rate: float) -> float: if not 0.0 <= u < 1.0: raise ValueError(f"u must lie in [0, 1), got {u!r}") if not rate > 0: raise ValueError(f"rate must be > 0, got {rate!r}") return -math.log1p(-u) / rate # -log(1 - u) / rate, accurate for tiny u; u = 0 gives 0
def poisson_arrivals(rate: float, horizon: float, rng: UniformSource) -> NDArray: # (argument checks elided) times: list[float] = [] t = 0.0 while True: t += exponential_icdf(rng.uniform(), rate) # one uniform per gap if t >= horizon: # the crossing arrival is not kept return np.asarray(times, dtype=np.float64) times.append(t)With , and uniforms , goes ; the third crosses and the call returns two times after three uniforms. The full solution is sampling.py.
Why this design
Section titled “Why this design”Start with cost. sample_categorical is per draw (the walk) with no extra memory; gumbel_max is and needs uniforms; AliasTable builds in time and memory and samples in per draw from one uniform; poisson_arrivals costs one uniform per arrival plus one.
The linear walk beats binary search here, which may surprise you. A searchsorted over a stored cumulative sum is , but the sampler’s distribution changes every token, so the cumulative sum is rebuilt each time anyway (), and the spec fixes a left-to-right accumulation so that two languages agree on exactly.
Vose beats the naive alias build. Walker’s original sorts or scans for the smallest and largest each step, or . Vose’s two worklists make each step and the whole build .
Exceptions beat sentinels. A fully masked row, an unnormalized vector, or is an upstream bug; returning id 0 would make a filtered token appear in generated text. Raising keeps those bugs visible.
Two tradeoffs are accepted knowingly. Gumbel-max uses uniforms per draw, more than the inverse CDF’s one, in exchange for needing no normalization. The alias table spends memory and setup to make each draw , which only pays off for many draws from one fixed distribution.
What can go wrong
Section titled “What can go wrong”A correct solution is checked against the hand examples, exact grids of uniforms, boundary inputs, and statistical fits. The full list follows, with why each case matters later.
| Case | Kind of check | Checks | Why it matters downstream |
|---|---|---|---|
| inverse CDF by hand | unit | the five draws of the hand example | everyone agrees on strict |
| alias table by hand | unit | the table encodes ; draws follow the rule on the built arrays and on the hand example’s table | the contract’s draw rule |
| Gumbel-max by hand | unit | the noise values and the winner of the hand example | the trick by hand |
| Poisson arrivals by hand | unit | two arrivals, three uniforms | the schedule the load generator replays |
| inverse CDF on a grid | statistical | a 1000-point grid of hits each id times | exact, no noise |
| a zero-probability id | boundary | with | a filtered token never leaks |
| a zero tail after rounding | boundary | when the sums stop below it | spec step 11’s fallback |
| the sampling spec’s last step | unit | the spec’s worked example ends on id 3 | the inference sampler calls this for step 11 |
| bad arguments | boundary | sums other than 1, negatives, NaN, 2-D, bad | upstream bugs fail loudly |
| Gumbel noise values | unit | ; rejected | the sign of the noise |
| Gumbel-max is softmax | statistical | 20 000 draws fit softmax (chi-square, ) | the theorem above |
| masks and ties | boundary | never wins; ties to the lowest id; invalid logits raise | masks from top-k and grammars |
| the alias table encodes | property | random with zeros, up to 64: within | any pairing order is fine |
| alias on a grid | statistical | grid uniforms give exact counts | column and coin from one |
| alias with a real generator | statistical | 20 000 PCG32 draws fit ; the id never appears | word2vec’s negative sampler |
| one uniform per alias draw | unit | 7 draws use 7 uniforms; n = 0 and n < 0 | the generator’s position is known |
| alias at column edges | boundary | exactly never yields a id | strict coin |
| a single outcome | boundary | for any | the smallest table |
| the exponential inverse CDF | unit | , , tiny accurate, bad args raise | log1p, not log |
| arrivals: horizon and draws | boundary | horizon 0, a gap of 0, invalid rate or horizon | is half open |
| arrivals: the rate | statistical | count mean and dispersion, gap mean from one long run | the process, not just the formula |
Most failures come from a handful of small slips, and several of them produce samplers that look random while sampling the wrong thing.
The comparisons are the first trap. Writing u <= c (or searchsorted(..., side="left")) lets return an id with ; the solution uses if u < c. Falling back to the last id instead of the last id with positive mass lets a zero-probability tail id come out when rounding leaves the sums below ; the solution uses np.flatnonzero(p > 0)[-1]. In the alias table, a coin test f <= prob keeps a zero-probability column at a column edge; the solution uses f < self.prob[i].
Warning: Adding Gumbel noise to probabilities instead of logits, or with the wrong sign, gives a sampler that looks random and has the wrong distribution. The noise is and it is added to logits.
The tie and mask rules are the second trap. Taking argmax over a reversed array sends ties to the highest id, and omitting the all- check makes a fully masked row return id 0. np.argmax takes the first maximum, and the all- row raises.
Reproducibility is the third. Two uniforms per alias draw give the correct distribution but different draws from the same seed, and the generator ends in the wrong place; the coin is the fractional part of u * k. Using for the exponential gives the same distribution, a different schedule, and infinity at ; the solution uses -math.log1p(-u) / rate.
The alias build has its own arithmetic slips. Not scaling columns by , computing the donor’s leftover as , or reading the coin from the alias column all make the table encode some other distribution; the solution uses scaled = p * n, (scaled[g] + scaled[s]) - 1.0, and self.prob[i] indexed by the drawn column.
Finally, keeping the arrival that crossed the horizon adds one extra request per window (the solution returns before times.append(t) once t >= horizon), and not checking that probs sums to 1 lets an unnormalized row sample as if its tail were empty (_check_probs with math.fsum catches it).
Where this leads
Section titled “Where this leads”These samplers are called all over the book series. The inference sampler’s step 11 in Sampling and logit processors is sample_categorical(q, rng.uniform()). word2vec draws negatives from AliasTable(unigram ** 0.75). BERT’s 80/10/10 masking draws the replacement with sample_categorical, and ELECTRA is a later call site of the same samplers. In this chapter, the bootstrap resamples with them and Rejection sampling and residual distributions uses them for speculative decoding’s residual draw. The load generator reimplements poisson_arrivals in Go from the same rule (a port, not a call).
Further reading
Section titled “Further reading”- Devroye, Non-Uniform Random Variate Generation (1986), chapters 2 and 3.
- Vose, “A Linear Algorithm for Generating Random Numbers with a Given Distribution” (1991).
- vLLM’s sampler,
random_sampleinvllm/v1/sample/ops/topk_topp_sampler.py: the exponential race,probs / Exp(1)then argmax, which is the Gumbel-max theorem without logs, batched on GPU. - numpy’s
Generator.choice(p=...)innumpy/random/_generator.pyx: a cumulative sum and a binary search (searchsorted) per batch of uniforms. - word2vec’s unigram table,
InitUnigramTableinword2vec.c: a quantized inverse CDF, an array of ids filled in proportion to , one index per draw.
Key terms
Section titled “Key terms”- Inverse CDF sampling: returning the first id whose cumulative probability exceeds a uniform draw.
- Gumbel distribution: the distribution of , with CDF .
- Gumbel-max trick: sampling from by taking the argmax of logits plus independent Gumbel noise.
- Alias table: equal columns, each holding at most two ids, that allow categorical draws.
- Vose’s algorithm: an construction of the alias table using small and large worklists.
- Exponential distribution: the waiting-time distribution with .
- Poisson process: events with independent exponential gaps; the count in a window of length is Poisson with mean .
Summary
Section titled “Summary”- The inverse CDF turns one uniform into id exactly when , an interval of length ; strict keeps zero-probability ids out, and the rounding fallback returns the last id with positive mass.
- Adding independent Gumbel noise to logits and taking the argmax samples exactly, with no normalization and no running sum.
- The alias method spends once to split the distribution into equal columns of two ids each, then draws in from one uniform.
- Poisson arrivals are cumulative exponential gaps , cut off at the horizon.
- Every sampler here is a deterministic function of its uniforms, so the same seed gives the same draws in Python, Rust, and Go.
Review questions
Section titled “Review questions”-
Why does
sample_categoricalfall back to the last id with rather than the last id?Answer
The fallback runs only when rounding left the running sum at or below (for example ten additions of 0.1 give and ). The true answer is then the id owning the end of , which is the last id with positive mass. If the tail ids have (filtered tokens), returning the last id would emit a token the sampler had removed.
-
In
AliasTable.sample, why is the coinx - iand not a secondrng.uniform()?Answer
Given the column , the fractional part is uniform on and independent of , so it is a valid coin. Using it keeps the cost at one uniform per draw, which fixes the generator’s position after
sample(rng, n)to exactly draws, matching every other port. A second uniform would give the right distribution but different draws from the same seed. -
Why must the coin test be
f < self.prob[i]and not<=?Answer
A column with belongs to an id with and must always redirect to its alias. At exactly, the coin is , and
0 <= 0would keep the column and emit the impossible id. Strict is the same rule as the inverse CDF’s: an empty interval contains nothing. -
Why does
gumbel_maxraise when every logit is but accept some entries?Answer
A logit is a mask: , so it never wins as long as some id is finite. If all are , every sum is and
np.argmaxwould return 0, a token the mask forbade. There is no distribution to sample, so the only honest answer is an error. -
Why
-math.log1p(-u)and not-math.log(u), when and have the same distribution?Answer
The distribution is the same but the schedule from a given seed is not: the load generator reimplements this in Go and must produce the same arrival times. And is a legal uniform: , while .
log1palso keeps full relative precision for tiny , where would round.