1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sun Mar 28 00:25:51 1993, David Metcalfe
28 .\" Modified Sat Jul 24 18:13:39 1993 by Rik Faith (faith@cs.unc.edu)
29 .\" Translated to German Sat May 18 19:20:00 1996 by Patrick Rother <krd@gulu.net>
30 .\" Modified Mon Jun 10 01:13:55 1996 by Martin Schulze (joey@linux.de)
32 .TH RANDOM 3 "18. Mai 1996" "GNU" "Bibliotheksfunktionen"
34 random, srandom, initstate, setstate \- Zufallszahlengenerator.
37 .B #include <stdlib.h>
39 .B long int random(void);
41 .BI "void srandom(unsigned int " seed );
43 .BI "char *initstate(unsigned int " seed ", char *" state ", int " n );
45 .BI "char *setstate(char *" state );
49 .BR random() -Funktion
50 benutzt einen Zufallsgenerator mit nicht-linearem additiven Feedback
51 mit einer vorgegebenen Tabellengröße von 31 long integers um
52 aufeinanderfolgende Pseudozufallszahlen im Rahmen von 0 bis
54 zurückzugeben. Die Periode dieses Zufallszahlengenerators ist sehr groß,
55 ungefähr 16*((2**31)\-1).
59 setzt ihr Argument als Ursprung für eine neue Folge von
60 Pseudozufalls-Ganzzahlen, welche von
62 geliefert werden. Diese Folgen sind wiederholbar durch Aufruf von
64 mit dem gleichen Ursprungswert. Wenn keine Ursprungswert angegeben wird
66 automatisch mit dem Ursprungswert 1 gestartet.
70 erlaubt es, ein Zustandsfeld
72 für den Gebrauch durch
74 zu initialisieren. Die Größe
76 des Zustandsfeldes wird von
78 benutzt, um zu entscheiden wie differenziert es ein Zufallszahlengenerator
79 benutzen soll \(em je größer das Zustandsfeld, desto besser die Zufallszahlen
81 ist der Ursprungswert für die Initialisierung, welcher den Startpunkt
82 für den Zufallszahlenfolge angibt und sicherstellt zum erneuten Starten
87 ändert das Zustandsfeld, welches von der Funktion
89 benutzt wird. Das Zustandsfeld
91 wird zum Erzeugen der Zufallszahlen benutzt bis zum nächsten Aufruf von
92 .BR initstate() " oder " setstate() ". " state
93 muss zuerst initialisiert werden durch Benutzen von
98 liefert einen Wert zwischen 0 und
102 liefert keinen Wert zurück.
104 .BR initstate() " und " setstate()
105 liefert einen Zeiger auf das vorherige Zustandsfeld.
109 Ein Zustandsfeld von weniger als 8 Byte wurde an
113 Aktuelle "optimale" Werte für die Größe
115 des Zustandsfeldes sind 8, 32, 64, 128 und 256 Byte; andere Werte
116 werden abgerundet auf den nächsten bekannten Wert. Verwendung von
117 weniger als 8 Byte erzeugt einen Fehler.