.\" -*- coding: UTF-8 -*- .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" 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) .\" Modified Sun Aug 20 21:47:07 2000, aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH RANDOM 3 "1 Noviembre 2020" GNU "Manual del Programador de Linux" .SH NOMBRE random, srandom, initstate, setstate \- generador de números aleatorios .SH SINOPSIS .nf \fB#include \fP .PP \fBlong random(void);\fP .PP \fBvoid srandom(unsigned \fP\fIseed\fP\fB);\fP .PP \fBchar *initstate(unsigned \fP\fIseed\fP\fB, char *\fP\fIstate\fP\fB, size_t \fP\fIn\fP\fB);\fP .PP \fBchar *setstate(char *\fP\fIstate\fP\fB);\fP .fi .PP .RS -4 Requisitos de Macros de Prueba de Características para glibc (véase \fBfeature_test_macros\fP(7)): .RE .PP .ad l \fBrandom\fP(), \fBsrandom\fP(), \fBinitstate\fP(), \fBsetstate\fP(): .RS 4 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE\ >=\ 500 || /* Glibc since 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE .RE .ad .SH DESCRIPCIÓN La función \fBrandom\fP() emplea un generador no lineal aditivo con retroalimentación de números aleatorios utilizando una tabla predeterminada de 31 enteros largos para devolver números pseudo\-aleatorios sucesivos en el rango de 0 a 2^31\ \-\ 1. El periodo de este generador de números aleatorios es muy grande, aproximadamente \fI16\ *\ ((2^31)\ \-\ 1)\fP. .PP La función \fBsrandom\fP() establece su argumento como la \fIsemilla\fP de una nueva secuencia de enteros seudo\-aleatorios que serán 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 función \fBrandom\fP() automáticamente asume una semilla de valor 1. .PP The \fBinitstate\fP() function allows a state array \fIstate\fP to be initialized for use by \fBrandom\fP(). The size of the state array \fIn\fP is used by \fBinitstate\fP() to decide how sophisticated a random number generator it should use\(emthe larger the state array, the better the random numbers will be. Current "optimal" values for the size of the state array \fIn\fP are 8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to the nearest known amount. Using less than 8 bytes results in an error. \fIseed\fP is the seed for the initialization, which specifies a starting point for the random number sequence, and provides for restarting at the same point. .PP La función \fBsetstate\fP() cambia el vector de estado usado por la función \fBrandom\fP(). El vector de estado, \fIestado\fP, se usa para la generación de números aleatorios hasta la siguiente llamada a \fBinitstate\fP() o \fBsetstate\fP(). El argumento \fIestado\fP debe haber sido inicializado primero mediante \fBinitstate\fP() o ser el resultado de una llamada previa a \fBsetstate\fP(). .SH "VALOR DEVUELTO" The \fBrandom\fP() function returns a value between 0 and \fI(2^31)\ \-\ 1\fP. The \fBsrandom\fP() function returns no value. .PP The \fBinitstate\fP() function returns a pointer to the previous state array. On error, \fIerrno\fP is set to indicate the cause. .PP On success, \fBsetstate\fP() returns a pointer to the previous state array. On error, it returns NULL, with \fIerrno\fP set to indicate the cause of the error. .SH ERRORES .TP \fBEINVAL\fP The \fIstate\fP argument given to \fBsetstate\fP() was NULL. .TP \fBEINVAL\fP Se ha especificado un vector de estado de menos de 8 bytes para \fBinitstate\fP(). .SH ATRIBUTOS Para obtener una explicación de los términos usados en esta sección, véase \fBattributes\fP(7). .TS allbox; lbw23 lb lb l l l. Interfaz Atributo Valor T{ \fBrandom\fP(), \fBsrandom\fP(), .br \fBinitstate\fP(), \fBsetstate\fP() T} Seguridad del hilo Multi\-hilo seguro .TE .SH "CONFORME A" POSIX.1\-2001, POSIX.1\-2008, 4.3BSD. .SH NOTAS The \fBrandom\fP() function should not be used in multithreaded programs where reproducible behavior is required. Use \fBrandom_r\fP(3) for that purpose. .PP Random\-number generation is a complex topic. \fINumerical Recipes in C: The Art of Scientific Computing\fP (William H.\& Press, Brian P.\& Flannery, Saul A.\& Teukolsky, William T.\& Vetterling; New York: Cambridge University Press, 2007, 3rd ed.) provides an excellent discussion of practical random\-number generation issues in Chapter 7 (Random Numbers). .PP For a more theoretical discussion which also covers many practical issues in depth, see Chapter 3 (Random Numbers) in Donald E.\& Knuth's \fIThe Art of Computer Programming\fP, volume 2 (Seminumerical Algorithms), 2nd ed.; Reading, Massachusetts: Addison\-Wesley Publishing Company, 1981. .SH ERRORES .\" http://sourceware.org/bugzilla/show_bug.cgi?id=15380 According to POSIX, \fBinitstate\fP() should return NULL on error. In the glibc implementation, \fIerrno\fP is (as specified) set on error, but the function does not return NULL. .SH "VÉASE TAMBIÉN" \fBgetrandom\fP(2), \fBdrand48\fP(3), \fBrand\fP(3), \fBrandom_r\fP(3), \fBsrand\fP(3) .SH COLOFÓN Esta página es parte de la versión 5.10 del proyecto Linux \fIman\-pages\fP. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en \%https://www.kernel.org/doc/man\-pages/. .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Gerardo Aburruzaga García y Miguel Pérez Ibars . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .