4Suite™ API Documentation

# ► Module Ft.Lib.Random

Thread-safe random number generation
We consider a physical source of entropy to be better than a simulated
one, so we will try to use one (/dev/urandom on posix, for example).
If a pseudo-random number generator is to be used, it should be seeded
from the physical source, if possible, rather than the usual custom of
seeding it from the system clock. Random number sources that are not
known to be thread-safe should be polled serially.
Copyright 2005 Fourthought, Inc. (USA).
Detailed license and copyright information: http://4suite.org/COPYRIGHT
Project home, documentation, distributions: http://4suite.org/

Functions: GetRandomBytes, Random |  |  |  | Fields: dev_rand_fd, pseudo_rng

## Functions

GetRandomBytes(numBytes)
Returns numBytes random bytes from the best RNG available
Random()
Returns a random float, n, where 0 <= n < 1

## Fields

dev_rand_fd = 8
pseudo_rng = <random.Random object>
Random number generator base class used by bound module functions.
Used to instantiate instances of Random to get generators that don't
share state. Especially useful for multi-threaded programs, creating
a different instance of Random for each thread, and using the jumpahead()
method to ensure that the generated sequences seen by each thread don't
overlap.
Class Random can also be subclassed if you want to use a different basic
generator of your own devising: in that case, override the following
methods: random(), seed(), getstate(), setstate() and jumpahead().
Optionally, implement a getrandombits() method so that randrange()
can cover arbitrarily large ranges.