Liking cljdoc? Tell your friends :D

datahike.pg.prng

PostgreSQL's pseudo-random generator, ported from src/common/pg_prng.c.

Ported rather than substituted for java.util.Random because it makes random() TESTABLE: SETSEED(0.5) followed by a fixed number of random() calls produces one exact sequence, so the differential against a real PostgreSQL is bit-for-bit rather than a smoke test that can only check the range.

xoroshiro128** with a splitmix64 seeder. All arithmetic is on Java longs, which are the same 64 bits as PostgreSQL's uint64 -- only the comparisons and the shift right differ, so every right shift here is the UNSIGNED one.

PostgreSQL's pseudo-random generator, ported from src/common/pg_prng.c.

Ported rather than substituted for java.util.Random because it makes
`random()` TESTABLE: `SETSEED(0.5)` followed by a fixed number of
`random()` calls produces one exact sequence, so the differential
against a real PostgreSQL is bit-for-bit rather than a smoke test
that can only check the range.

xoroshiro128** with a splitmix64 seeder. All arithmetic is on Java
longs, which are the same 64 bits as PostgreSQL's uint64 -- only the
comparisons and the shift right differ, so every right shift here is
the UNSIGNED one.
raw docstring

draw-double!clj

(draw-double! cell)

Advance cell and return the next double in [0,1).

Advance `cell` and return the next double in [0,1).
sourceraw docstring

fseed-stateclj

(fseed-state fseed)

pg_prng_fseed: scale the [-1,1] argument by 2^52-1 and truncate toward zero, exactly as the C cast to int64 does.

pg_prng_fseed: scale the [-1,1] argument by 2^52-1 and truncate toward
zero, exactly as the C cast to int64 does.
sourceraw docstring

make-session-stateclj

(make-session-state)

A per-session PRNG cell. PostgreSQL seeds from the clock and the backend PID until SETSEED is called.

A per-session PRNG cell. PostgreSQL seeds from the clock and the
backend PID until SETSEED is called.
sourceraw docstring

next-doubleclj

(next-double state)

pg_prng_double: the top 52 bits scaled into [0,1). Returns [value new-state].

pg_prng_double: the top 52 bits scaled into [0,1). Returns
`[value new-state]`.
sourceraw docstring

next-u64clj

(next-u64 [s0 s1])

One xoroshiro128** step. Returns [value new-state].

One xoroshiro128** step. Returns `[value new-state]`.
sourceraw docstring

seed-stateclj

(seed-state seed)

pg_prng_seed: two splitmix64 draws from the seed. The all-zero state is invalid for xoroshiro, and PostgreSQL substitutes a fixed pair.

pg_prng_seed: two splitmix64 draws from the seed. The all-zero state
is invalid for xoroshiro, and PostgreSQL substitutes a fixed pair.
sourceraw docstring

set-seed!clj

(set-seed! cell fseed)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close