Next: , Previous: , Up: random utils   [Index]


49.7.3 Specialised vector functions

The auxiliary library (vicare crypto randomisations vectors) exports bindings specialised to handle vectors and randomness sources; it is based on both (vicare crypto randomisations) and (vicare containers vectors). Arguments to the following functions follow the same conventions established for (vicare containers vectors) and (vicare crypto vectors low). Interface conventions

Function: random-vector-unfold-numbers number-maker number-of-numbers

Given the closure number-maker returning a random number, build and return a new list of number-of-numbers random numbers.

Function: %random-vector-shuffle source vec start past
Macro: random-vector-shuffle V source

Build a new vector copying the selected subvector, then shuffle it using randomness from the given source. Return the new vector.

Function: %random-vector-shuffle! source vec start past
Macro: random-vector-shuffle! V source

Shuffle the selected subvector using randomness from the given source. Return the shuffled vector itself.

Function: %random-vector-sample source vec start past
Macro: random-vector-sample V source

Return a closure that, when evaluated with no arguments, returns a randomly selected item from the selected subvector, using randomness from source.

Function: %random-vector-sample-population source len vec start past
Macro: random-vector-sample-population V len source

Return a closure that, when evaluated with no arguments, returns a vector of len items randomly selected from the selected subvector of vec, using randomness from source.

Function: random-integers-with-sum requested-sum number-of-numbers inclusive-min inclusive-max source

Return a vector of length number-of-numbers, holding random integers in the range delimited by inclusive-min and inclusive-max, generated using randomness from source. The integers are such that their sum equals requested-sum.

Function: random-reals-with-sum requested-sum tolerance number-of-numbers exclusive-min exclusive-max source

Return a vector of length number-of-numbers, holding random reals in the range delimited by exclusive-min and exclusive-max, generated using randomness from source. The numbers are such that their sum equals approximately requested-sum with tolerance:

(< (- (abs tolerance))
   (abs (- requested-sum actual-sum))
   (abs tolerance))
⇒ #t

Next: , Previous: , Up: random utils   [Index]