random_permutation {noah}R Documentation

Generate a lazy non-repeating random number generator

Description

Generates a function that provides lazy number generation from a random permutation of integers 1 to n without repetition. The numbers are generated using the Fisher-Yates algorithm and run length encoding (RLE) is used to keep memory use for the storage of used/available numbers minimal.

Usage

random_permutation(n)

Arguments

n

Upper limit for random numbers (inclusive)

Value

A function f(m) that returns m random numbers from the random permutation of integers 1 to n without repetition,. If all available numbers 1 to n have been returned but more are requested, the function throws an error.


[Package noah version 0.1.0 Index]