summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/rand.c
Commit message (Collapse)AuthorAgeFilesLines
* Back out "drop first N values" method of removing monotonically increasedache2003-02-171-7/+1
| | | | | | | | | | | | | | | seed->first value correlation. It breaks rand_r()... Other possible methods like shuffling inside aray will breaks rand_r() too, because it assumes only one word state, i.e. nothing extra can be added after seed assignment in srand(). BTW, for old formulae seed->first value correlation is not so monotonically increased as with other Linear Congruential Generators of this type only becase arithmetic overflow happens. But overflow affects distribution and lower bits very badly, as many articles says, such type of overflow not improves PRNG. So, monotonically increased seed->first value correlation problem remains...
* Since we drop NSHUFF values now, set default seed to what it becomesache2003-02-051-3/+3
| | | | after srand(1)
* For rand(3) and random(3) TYPE_0 drop NSHUFF values right after srand{om}()ache2003-02-041-1/+7
| | | | | | | to remove part of seed -> 1st value correlation. Correlation still remains because of algorithm limits. Note that old algorithm have even stronger correlation, especially in the lower bits area, but not eye-visible, as current one.
* Park & Miller PRNG can be safely initialized with any value but 0 and stuckache2003-02-031-1/+4
| | | | | | | at 0 as designed. Its BSD adaptation tries to fight it by mapping 0 to 2147483647 after calculation, but this method not works since 2147483647 seed returns to 0 again on the next interation. Instead of after calculation mapping, map 0 to another value _before_ calculation, so it never stucks.
* For some combinations of variable sizes and RAND_MAX value rand_r()ache2003-02-021-2/+4
| | | | may store less amount bits for seed, than available. Fix it.
* Add missing #include "namespace.h".tjr2003-01-031-0/+1
|
* Fix the style of the SCM ID's.obrien2002-03-221-2/+2
| | | | I believe have made all of libc .c's as consistent as possible.
* Add a long-overdue nail to the deprecated /dev/urandom interfacemarkm2001-10-301-1/+1
| | | | | by asking some things that need unpredictable numbers to read /dev/random instead.
* urandom(4) -> random(4) in comments.dd2001-06-071-1/+1
| | | | | | | PR: 27858 Submitted by: Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp> Reviewed by: md5(1) Approved by: markm
* Add #include "un-namespace.h"ache2001-04-231-0/+1
|
* srand*dev() fallback code: change ^getpid() to ^(getpid() << 16) to allowache2001-04-231-1/+1
| | | | change of high word part too to produce more interesting seed distribution.
* Add sranddev() since srand() is not vary much with seed, typical timeache2001-04-231-0/+34
|
* Use formula with better random distribution for rand()ache2001-02-271-0/+26
| | | | | | Even better formula from random() could not be intetgrated because rand_r() supposed to store its state in the single variable (but table needed for random() algorithm integration).
* Added Posix rand_r function.wes1999-05-241-1/+52
|
* BSD 4.4 Lite Lib Sourcesrgrimes1994-05-271-0/+54
OpenPOWER on IntegriCloud