summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/rand.c
Commit message (Collapse)AuthorAgeFilesLines
* Back out "drop first N values" method of removing monotonically increasedAndrey A. Chernov2003-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... Notes: svn path=/head/; revision=111026
* Since we drop NSHUFF values now, set default seed to what it becomesAndrey A. Chernov2003-02-051-3/+3
| | | | | | | after srand(1) Notes: svn path=/head/; revision=110421
* For rand(3) and random(3) TYPE_0 drop NSHUFF values right after srand{om}()Andrey A. Chernov2003-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. Notes: svn path=/head/; revision=110321
* Park & Miller PRNG can be safely initialized with any value but 0 and stuckAndrey A. Chernov2003-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. Notes: svn path=/head/; revision=110280
* For some combinations of variable sizes and RAND_MAX value rand_r()Andrey A. Chernov2003-02-021-2/+4
| | | | | | | may store less amount bits for seed, than available. Fix it. Notes: svn path=/head/; revision=110236
* Add missing #include "namespace.h".Tim J. Robbins2003-01-031-0/+1
| | | | Notes: svn path=/head/; revision=108625
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-2/+2
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Add a long-overdue nail to the deprecated /dev/urandom interfaceMark Murray2001-10-301-1/+1
| | | | | | | | by asking some things that need unpredictable numbers to read /dev/random instead. Notes: svn path=/head/; revision=85752
* urandom(4) -> random(4) in comments.Dima Dorfman2001-06-071-1/+1
| | | | | | | | | | PR: 27858 Submitted by: Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp> Reviewed by: md5(1) Approved by: markm Notes: svn path=/head/; revision=77851
* Add #include "un-namespace.h"Andrey A. Chernov2001-04-231-0/+1
| | | | Notes: svn path=/head/; revision=75863
* srand*dev() fallback code: change ^getpid() to ^(getpid() << 16) to allowAndrey A. Chernov2001-04-231-1/+1
| | | | | | | change of high word part too to produce more interesting seed distribution. Notes: svn path=/head/; revision=75862
* Add sranddev() since srand() is not vary much with seed, typical timeAndrey A. Chernov2001-04-231-0/+34
| | | | Notes: svn path=/head/; revision=75845
* Use formula with better random distribution for rand()Andrey A. Chernov2001-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). Notes: svn path=/head/; revision=73156
* Added Posix rand_r function.Wes Peters1999-05-241-1/+52
| | | | Notes: svn path=/head/; revision=47474
* BSD 4.4 Lite Lib SourcesRodney W. Grimes1994-05-271-0/+54
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573