irandom
1 Random Numbers
irandom-context?
make-irandom-context
current-irandom-context
irandom
irandom-fixnum
irandom-32
irandom-bytes
irandom-list-32
irandom-fxvector
irandom-fxvector-32
irandom-flvector
irandom-u32vector
irandom-u64vector
irandom-f64vector
2 Random UUID Generation
uuid-string
uuid-bytes
uuid-string?
8.1

irandom

hkrish

 (require irandom) package: irandom

Racket implementation of Bob Jenkins’ ISAAC pseudo-random number generator.

At the moment, this module requires racket CS variant running on a 64-bit platform.

ISAAC: a fast cryptographic random number generator

"ISAAC (Indirection, Shift, Accumulate, Add, and Count) generates 32-bit random numbers. ... Cycles are guaranteed to be at least 240 values long, and they are 28295 values long on average. The results are uniformly distributed, unbiased, and unpredictable unless you know the seed."

http://burtleburtle.net/bob/rand/isaacafa.html

Output of this implementation has been tested with output of the original source for conformity and correctness, as well as the dieharder random number generator test suit and passes all the tests —see the results in the "test/data" directory.

    1 Random Numbers

    2 Random UUID Generation

1 Random Numbers

procedure

(irandom-context? v)  boolean

  v : any/c
Returns #t if v is an irandom-context, #f otherwise.

procedure

(make-irandom-context)  irandom-context

Returns a new irandom-context. The irandom-context is used by all functions in this module via the parameter current-irandom-context for generating random numbers. The new irandom-context is seeded with bytes from crypto-random-bytes.

A parameter that determines the irandom-context used by all functions in this module.

procedure

(irandom)  (and/c flonum? (>=/c 0) (</c 1))

Returns a random flonum between 0 (inclusive) and 1 (exclusive).

procedure

(irandom-fixnum)  fixnum?

Returns a random fixnum.

procedure

(irandom-32)  fixnum?

Returns a random fixnum that is 32-bits in size. On 64-bit platforms, the leading bits are 0.

procedure

(irandom-bytes n)  bytes?

  n : (and/c fixnum? (>=/c 0))
Generates n random bytes.

procedure

(irandom-list-32 n)  list?

  n : (and/c fixnum? (>=/c 0))
Returns a list containing n 32-bit random numbers.

procedure

(irandom-fxvector n)  fxvector?

  n : (and/c fixnum? (>=/c 0))
Returns a fxvector containing n random numbers.

procedure

(irandom-fxvector-32 n)  fxvector?

  n : (and/c fixnum? (>=/c 0))
Returns a fxvector containing n 32-bit random numbers.

procedure

(irandom-flvector n)  flvector?

  n : (and/c fixnum? (>=/c 0))
Returns a flvector containing n random floating point numbers, each between 0 (inclusive) and 1 (exclusive).

procedure

(irandom-u32vector n)  u32vector?

  n : (and/c fixnum? (>=/c 0))
Returns a u32vector containing n random 32-bit integers.

procedure

(irandom-u64vector n)  u64vector?

  n : (and/c fixnum? (>=/c 0))
Returns a u64vector containing n random 64-bit integers.

procedure

(irandom-f64vector n)  f64vector?

  n : (and/c fixnum? (>=/c 0))
Returns a f64vector containing n random double-precision floating point numbers, each between 0 (inclusive) and 1 (exclusive).

2 Random UUID Generation

 (require irandom/uuid) package: irandom

Following bindings are exported by both irandom, and irandom/uuid.

procedure

(uuid-string)  (and/c string? immutable?)

Generates an immutable version-4 random UUID string using random bytes generated by irandom-bytes.

procedure

(uuid-bytes)  (and/c bytes? immutable?)

Generates an immutable version-4 random UUID bytestring using random bytes generated by irandom-bytes.

procedure

(uuid-string? v)  boolean?

  v : any/c
Checks if the input is a string or bytestring and conforms to the version-4 random UUID format.