sample

open override fun sample(random: Random): Int(source)

Draws a single random value from this Zipf distribution using inverse transform sampling.

Uses binary search on the precomputed CDF table for O(log n) per draw.

Return

a random integer in [1, n].

Parameters

random

the source of randomness.