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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
.\" 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 Sat Jul 24 19:46:03 1993 by Rik Faith (faith@cs.unc.edu)
.\"
.\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
.\" all rights reserved.
.\" Translated Mon Jan 20 20:04:05 JST 1997
.\" by YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
.\"
.\" WORD: internal buffer Хåե
.\"
.TH DRAND48 3 "July 2, 1993" "" "Linux Programmer's Manual"
.SH ̾
drand48, erand48, lrand48, nrand48, mrand48, jrand48,
srand48, seed48, lcong48 \- ʬۤ뵿ؿ
.SH
.nf
.B #include <stdlib.h>
.sp
.B double drand48(void);
.sp
.BI "double erand48(unsigned short " xsubi [3]);
.sp
.B long int lrand48(void);
.sp
.BI "long int nrand48(unsigned short " xsubi [3]);
.sp
.B long int mrand48(void);
.sp
.BI "long int jrand48(unsigned short " xsubi [3]);
.sp
.BI "void srand48(long int " seedval );
.sp
.BI "unsigned short *seed48(unsigned short " seed16v [3]);
.sp
.BI "void lcong48(unsigned short " param [7]);
.fi
.SH
δؿƱ르ꥺ48ӥå黻Ѥ
롣
.PP
\fBdrand48()\fPؿ\fBerand48()\fPؿϡ[0.0, 1.0)
ʬۤư¿֤ͤ
.PP
\fBlrand48()\fPؿ\fBnrand48()\fPؿ02^31δ֤ǰʬۤ
Υ֤
.PP
\fBmrand48()\fPؿ\fBjrand48()\fPؿ
\-2^312^31δ֤ǰʬۤդ֤
.PP
\fBsrand48()\fPؿ\fBseed48()\fPؿ\fBlcong48()\fPؿϽؿ
Ǥ롣
\fBdrand48()\fPؿ\fBlrand48()\fPؿޤ\fBmrand48()\fP
ѤˡνؿΤ줫Ƥ֤٤Ǥ롣
ؿ
\fBerand48()\fP\fBnrand48()\fP\fBjrand48()\fPϽ
ؿƤ֤ȤɬפȤʤ
.PP
Ƥ뤹٤Ƥδؿ48ӥåȤ
(\fIXi\fP)뤳Ȥ
ǽƤ롣ˡϰʲƱμˤ롣
.sp
.nf
.RS
.B Xn+1 = (aXn + c) mod m,
.RE
.fi
.sp
n >= 0 Ǥ롣
ѥ\fIm\fP = 2^48Ǥ뤿ᡢ48ӥå黻ԤƤ롣
\fBlcong48()\fPƤФƤʤ硢\fIa\fP\fIc\fPϰʲμͿ롣
.sp
.nf
.RS
.B a = 0x5DEECE66D
.B c = 0xB
.RE
.fi
.sp
ؿ\fBdrand48()\fP\fBerand48()\fP\fBlrand48()\fP\fBnrand48()\fP
\fBmrand48()\fP\fBjrand48()\fP֤ͤϼΤ褦ˤƷ롣
Ϥˡ48ӥåȤ\fIXi\fP롣
ơ֤٤ǡη˰¸Ŭڤ
ӥåȿ\fIXi\fPξ̥ӥåȤ饳ԡ롣
Ǹˡ֤ͤͤѴ롣
.PP
ؿ\fBdrand48()\fP\fBlrand48()\fP\fBmrand48()\fP
Ǹ줿48ӥåȤ\fIXi\fPХåե˳Ǽ롣
ηΰ\fIxsubi\fP˸ġ\fIXi\fPͤ
ǼǤ褦ΰݤ뤳Ȥ
ؿ\fBerand48()\fP\fBnrand48()\fP\fBjrand48()\fPϡ
ƤӽФ¦Υץ᤹롣
δؿϡϤƤδؿƤ\fIXi\fPνͤ
뤳Ȥǽ롣
.PP
ؿ\fBsrand48()\fPϡ\fIXi\fP
32ӥåȤ\fIseedval\fPꤹ롣
̤16ӥåȤϡŬ˷줿ͤǤ0x330Eꤵ롣
.PP
ؿ\fBseed48()\fPϡ\fIXi\fPͤ
ηǤ\fIseed16v\fPǻꤵ줿48ӥåȤͤꤹ롣
\fIXi\fPͤХåե˥ԡ졢ΥХåեؤΥݥ
\fBseed48()\fPˤä֤롣
.PP
ؿ\fBlcong48()\fPϻѼԤ\fIXi\fP\fIa\fP\fIc\fP
ͤꤹ뤿δؿǤ롣
ηǤϤ줾졢\fIparam[0-2]\fP\fIXi\fP
\fIparam[3-5]\fP\fIa\fP\fIparam[6]\fP\fIc\fPꤹ
Ǥ롣
\fBlcong48()\fPƤФ줿ǡ
\fBsrand48()\fPޤ\fBseed48()\fPƤ֤ȡҤ\fIa\fP\fIc\fP
ɸͤƤꤵ롣
.SH
SVID 3
.SH ջ
δؿSVID\ 3ˤäƻ٤Ƥ롣
SVID\ 3rand(3)˻Ѥ٤ȵҤƤ롣
.SH Ϣ
.BR rand (3),
.BR random (3)
|