File: random.3

package info (click to toggle)
manpages-es 1.24a-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,256 kB
  • ctags: 7
  • sloc: makefile: 66; sh: 62
file content (94 lines) | stat: -rw-r--r-- 4,274 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\" Modified Sun Mar 28 00:25:51 1993, David Metcalfe
.\" Modified Sat Jul 24 18:13:39 1993 by Rik Faith (faith@cs.unc.edu)
.\" Translated into Spanish Thu Mar  5 15:51:13 CET 1998 by Gerardo
.\" Aburruzaga Garca <gerardo.aburruzaga@uca.es>
.\"
.TH RANDOM 3  "5 Marzo 1998" "GNU" "Manual del Programador de Linux"
.SH NOMBRE
random, srandom, initstate, setstate \- generador de nmeros aleatorios.
.SH SINOPSIS
.nf
.B #include <stdlib.h>
.sp
.B long int random(void);
.snl
.BI "void srandom(unsigned int " semilla );
.nl
.BI "char *initstate(unsigned int " semilla ", char *" estado ", int " n );
.nl
.BI "char *setstate(char *" estado );
.fi
.SH DESCRIPCIN
La funcin \fBrandom()\fP emplea un generador no lineal aditivo con
retroalimentacin de nmeros aleatorios utilizando una tabla
predeterminada de 31 enteros largos para devolver nmeros
pseudo-aleatorios sucesivos en el rango de 0 a \fBRAND_MAX\fR.
El periodo de este generador de nmeros aleatorios es muy grande,
aproximadamente 16*((2**31)\-1).
.PP
La funcin \fBsrandom()\fP establece su argumento como la
\fIsemilla\fP de una nueva secuencia de enteros seudo-aleatorios que
sern devueltos por \fBrandom()\fP en secuencia.
Estas secuencias son repetibles si se llama a \fBsrandom()\fP con el
mismo valor para la semilla. Si no se proporciona ninguna semilla,
porque no se llama a \fBsrandom()\fP, la funcin \fBrandom()\fP
automticamente asume una semilla de valor 1.
.PP
La funcin \fBinitstate()\fP permite inicializar un vector de estado,
\fIestado\fP, para el uso por parte de \fBrandom()\fP.  El tamao del
vector de estado, \fIn\fP, es usado por \fBinitstate()\fP para decidir
cun sofisticado debe ser el generador de nmeros aleatorios que
debera usar: cuanto ms grande sea el vector de estado, ms
aleatorios sern los nmeros. El argumento \fIsemilla\fP es la semilla para la 
inicializacin, que especifica un punto de arranque para la secuencia
de nmeros aleatorios, y hace posible recomenzar en el mismo punto.
.PP
La funcin \fBsetstate()\fP cambia el vector de estado usado por la funcin
\fBrandom()\fP.  El vector de estado, \fIestado\fP, se usa para la
generacin de nmeros aleatorios hasta la siguiente llamada a
\fBinitstate()\fP o \fBsetstate()\fP.  El argumento \fIestado\fP debe
haber sido inicializado primero mediante \fBinitstate()\fP.
.SH "VALOR DEVUELTO"
La funcin \fBrandom()\fP devuelve un valor entre 0 y RAND_MAX.
La funcin \fBsrandom()\fP no devuelve nada. Las funciones \fBinitstate()\fP 
y \fBsetstate()\fP devuelven un puntero al vector de estado anterior.
.SH "ERRORES"
.TP
.B EINVAL
Se ha especificado un vector de estado de menos de 8 bytes para
\fBinitstate()\fP.
.SH OBSERVACIONES
Los valores actuales "ptimos" para el tamao del vector de estado,
\fIn\fP, son 8, 32, 64, 128, y 256 bytes; otras cantidades sern
redondeadas por abajo hasta la cantidad conocida ms cercana. Utilizar
menos de 8 bytes producir un error.
.SH "CONFORME A"
BSD 4.3
.SH "VASE TAMBIN"
.BR rand "(3), " srand (3)