(next-instant random)(next-instant random start-year end-year)Return a random instant between the beginning of start-year (inclusive)
and the beginning of (inc end-year) (exclusive).
Defaults to the current calendar year and the preceding ten years.
Return a random instant between the beginning of `start-year` (inclusive) and the beginning of `(inc end-year)` (exclusive). Defaults to the current calendar year and the preceding ten years.
(next-uuid random)Generate a version-4 UUID using the supplied RNG, matching java.util.UUID/randomUUID idioms.
Generate a version-4 UUID using the supplied RNG, matching java.util.UUID/randomUUID idioms.
(rand-gaussian random n)Draw an index in [0, n) from a half-normal distribution: |N(0, 1)| / 3, scaled by n. Low indices are the most likely; draws past n (about 0.3%) are clamped to n - 1. Returns nil if n is not positive.
Draw an index in [0, n) from a half-normal distribution: |N(0, 1)| / 3, scaled by n. Low indices are the most likely; draws past n (about 0.3%) are clamped to n - 1. Returns nil if n is not positive.
(shuffle random coll)Shuffle a collection using the provided RNG (Fisher-Yates).
Shuffle a collection using the provided RNG (Fisher-Yates).
(weighted-nth rng weights xs)Draw a single element from xs with non-negative weights. Returns nil if xs empty. If all weights are zero, falls back to uniform.
Draw a single element from xs with non-negative weights. Returns nil if xs empty. If all weights are zero, falls back to uniform.
(weighted-sample-fn weighted-items)Aliased random sampler:
https://www.peterstefek.me/alias-method.html
Given a seq of [item weight] pairs, return a function who when given a Random will return an item according to the weight distribution.
Building the table is O(n log n); each draw is O(1). Prefer this over
weighted-nth when drawing repeatedly from the same weights.
Aliased random sampler: https://www.peterstefek.me/alias-method.html Given a seq of [item weight] pairs, return a function who when given a Random will return an item according to the weight distribution. Building the table is O(n log n); each draw is O(1). Prefer this over `weighted-nth` when drawing repeatedly from the same weights.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |