polydat 0.1.0

Polydat — generation kernel for deterministic variate generation in nb-rs (formerly nbrs-variates)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// hello_world.gk — The simplest possible GK kernel.
//
// One input coordinate, one hash, one bounded output.
// This is the "hello world" of variate generation: take a cycle
// number and produce a pseudo-random value in a useful range.

// Declare the input coordinate space. Here we have a single
// dimension called "cycle" — the engine's iteration counter.
input cycle: u64

// Hash the cycle to produce a pseudo-random but deterministic u64.
// Without this, sequential cycle values (0, 1, 2, ...) would produce
// sequential outputs. The hash disperses them across the u64 space.
hashed := hash(cycle)

// Bound the hashed value to a useful range.
// This gives us a user_id between 0 and 999,999.
user_id := mod(hashed, 1000000)