home *** CD-ROM | disk | FTP | other *** search
-
-
-
- RANDOM(3) MINTLIB LIBRARY FUNCTIONS RANDOM(3)
-
-
- N✓NA✓AM✓ME✓E
- random, srandom, initstate, setstate - improved random
- number generator; routines for changing generators
-
- S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
- #include <unistd.h>
-
- long random(void);
-
- void srandom (unsigned int seed);
-
- char * initstate (unsigned int seed, char *arg_state, int n);
-
- char * setstate (char *arg_state);
-
- D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
- random is a good random number generator returning pseudo-
- random numbers in the range from 0 to 2^31 - 1. The random
- number generator has a very large period.
-
- random/srandom have (almost) the same calling sequence and
- initialization properties as rand/srand. The difference is
- that rand produces a much less random sequence, while all
- the bits generated by random are useable.
-
- The initstate routine allows a state array, passed in an
- argument, to be initialized for future use. The size of
- the state array (in bytes) is used by initstate to decide
- how sophisticated a random number generator it should use
- - the more state, the better the random numbers will be.
- Good values for the amount of state information are 32,
- 64, 128 and 256 bytes. The seed for the initialization
- (which specifies a starting point for the random number
- sequence, and provides for restarting at the same point)
- is also an argument. initstate returns a pointer to the
- previous state information array.
-
- Once a state array has been initialized, the setstate rou-
- tine provides for rapid switching between states. set-
- state returns a pointer to the previous state array; its
- argument state array is used for further random number
- generation until the next call to initstate or setstate.
-
- Once a state array has been initialized, it may be
- restarted at a different point either by calling initstate
- (with the desired seed, the state array, and its size) or
- by calling both setstate (with the state array) and sran-
- dom (with the desired seed). The advantage of calling both
- setstate and srandom is that the size of the state array
- does not have to be remembered after it is initialized.
-
- S✓SE✓EE✓E A✓AL✓LS✓SO✓O
- r✓ra✓an✓nd✓d(✓(3✓3)✓),✓, s✓sr✓ra✓an✓nd✓d(✓(3✓3)✓)
-
-
-
-
- MiNT docs 0.1 3 March 1993 1
-
-
-
-
-
- RANDOM(3) MINTLIB LIBRARY FUNCTIONS RANDOM(3)
-
-
- N✓NO✓OT✓TE✓ES✓S
- See the source file (random.c) for complete information
- and comments on the workings of the random number genera-
- tor.
-
- random is slower than rand.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MiNT docs 0.1 3 March 1993 2
-
-
-