Differences between version 2 and revision by previous author of drand48(3).
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Friday, March 26, 2004 8:08:30 am | by JohnMcPherson | Revert |
Older page: | version 1 | Last edited on Tuesday, June 4, 2002 12:24:16 am | by perry | Revert |
@@ -1,117 +1,65 @@
-DRAND48
-!!!DRAND48
-NAME
-SYNOPSIS
-DESCRIPTION
-CONFORMING TO
-NOTES
-SEE ALSO
-----
!!NAME
+drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 - generate uniformly distributed pseudo-random numbers
-
-drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 - generate uniformly distributed pseudo-random numbers
!!SYNOPSIS
+ __#include <stdlib.h>__
-__#include
-__ ''xsubi''__[[3]);
-long int lrand48
(void);
-long int nrand48(unsigned short int__ ''xsubi''__[[3]);
-long int mrand48(void);
-long int jrand48(unsigned short int__ ''xsubi''__[[3]);
-void srand48(long int__ ''seedval''__);
-unsigned short int *__''seed48(unsigned''__short__''int'' __seed16v [[3]);
-void lcong48(unsigned short int__ ''param''__[[7]);
-
__
-!!DESCRIPTION
+
__double drand48
(void);__
+ __double erand48(unsigned short __ ''xsubi'' __[[3]);__
-These functions generate pseudo-random numbers using the
-linear congruential algorithm and 48-bit integer
-arithmetic.
+ __long int lrand48(void);__
+ __long int nrand48(unsigned short __ ''xsubi'' __[[3]);__
-The
__drand48
()__ and __erand48()__ functions return
-non-negative double-precision floating-point values
-uniformly distributed between [[., 1.).
+
__long int mrand48
(void
);
__
+ __long int jrand48(unsigned short __ ''xsubi'' __[[3]);__
-The
__lrand48
()
__ and
__nrand48(
)__ functions return
-non-negative long integers uniformly distributed between
-and 2^31.
+
__void srand48
(long int
__ ''seedval''
__);
__
+ __unsigned short *seed48(unsigned short __ ''seed16v'' __[[3]);__
-The
__mrand48
()
__ and
__jrand48(
)__ functions return
-signed long integers uniformly distributed between -2^31 and
-2^31.
+
__void lcong48
(unsigned short
__ ''param''
__[[7]
);
__
-The __srand48()__, __seed48()__ and __lcong48()__
-functions are initialization functions, one of which should
-be called before using __drand48()__, __lrand48()__ or
-__mrand49()__. The functions __erand48()__,
-__nrand48()__ and __jrand48()__ do not require an
-initialization function to be called first.
+!!DESCRIPTION
+These functions generate pseudo-random numbers using the linear congruential algorithm and 48-bit integer arithmetic.
-All the
functions work by generating a sequence of 48
-bit
-integers, ''Xi''
, according to the linear congruential
-formula:
+The __drand48()__ and __erand48()__
functions return non
-negative double-precision floating-point values uniformly distributed between [[.
, 1.).
+The __lrand48()__ and __nrand48()__ functions return non-negative long integers uniformly distributed between 0 and 2^31.
-__ Xn+1 =
(aXn + c
) mod m, where n
-
__The parameter ''m'' = 2^48, hence 48-bit integer arithmetic is performed. Unless
__lcong48
()__ is called, ''a''
and ''c'' are given by:
+The
__mrand48
()__ and
__jrand48
()__ functions return signed long integers uniformly distributed between -2^31
and 2^31.
+The __srand48()__, __seed48()__ and __lcong48()__ functions are initialization functions, one of which should be called before using __drand48()__, __lrand48()__ or __mrand48()__. The functions __erand48()__, __nrand48()__ and __jrand48()__ do not require an initialization function to be called first.
-__ a = 0x5DEECE66D
-c = 0xB
-__The value returned by any of
the functions __drand48()__, __erand48()__, __lrand48()__, __nrand48()__, __mrand48()__ or __jrand48()__ is computed
by first
generating the next
48-bit ''Xi'' in the sequence. Then the appropriate number of bits
, according to the type of data item to be returned, is copied from the high-order bits of ''Xi'' and transformed into the returned value.
+All
the functions work
by generating a sequence of
48-bit integers,
''Xi'', according to the linear congruential formula:
+ __Xn+1 = (aXn + c) mod m, where n >= 0__
-The functions __drand48()__
, __lrand48()__ and
-__mrand48()__ store the last
48-bit ''Xi'' generated
-in an internal buffer
. The functions
__erand48
()__,
-__nrand48()__ and __jrand48()__ require the calling
-program to provide storage for the successive
''Xi
''
-values in the array argument
''xsubi
''. The functions
are
-initialized
by placing the initial value of ''Xi'' into
-the array before calling the function for the first
-time.
+The parameter ''m'' = 2^48
, hence
48-bit integer arithmetic is performed
. Unless
__lcong48
()__ is called
, ''a
'' and
''c
'' are given
by:
+ __a = 0x5DEECE66D__
+ __c = 0xB__
-The initializer function
__srand48
()__ sets
the high
-order 32
-bits of
''Xi'' to the argument
''seedval
''.
-The low order 16-bits are set to
the arbitrary
value
-0x330E
.
+The value returned by any of the functions
__drand48
()__, __erand48()__, __lrand48()__, __nrand48()__, __mrand48()__ or __jrand48()__ is computed by first generating
the next 48
-bit
''Xi'' in the sequence. Then the appropriate number of bits, according
to the type of data item to be returned, is copied from the high-order bits of
''Xi
'' and transformed into
the returned
value.
+The functions __drand48()__, __lrand48()__ and __mrand48()__ store the last 48-bit ''Xi'' generated in an internal buffer. The functions __erand48()__, __nrand48()__ and __jrand48()__ require the calling program to provide storage for the successive ''Xi'' values in the array argument ''xsubi''. The functions are initialized by placing the initial value of ''Xi'' into the array before calling the function for the first time.
-The initializer function __seed48
()__ sets the value
of
-
''Xi'' to the 48-bit value specified in the array
-
argument ''seed16v
''. The previous
value of ''Xi'' is
-copied into an internal buffer and a pointer to this buffer
-is returned by __seed48()__
.
+The initializer function __srand48
()__ sets the high order 32-bits
of ''Xi'' to the argument ''seedval
''.
The low order 16-bits are set to the arbitrary
value 0x330E
.
+The initializer function __seed48()__ sets the value of ''Xi'' to the 48-bit value specified in the array argument ''seed16v''. The previous value of ''Xi'' is copied into an internal buffer and a pointer to this buffer is returned by __seed48()__.
+
+The initialization function __lcong48()__ allows the user to specify initial values for ''Xi'', ''a'' and ''c''. Array argument elements ''param[[0-2]'' specify ''Xi'', ''param[[3-5]'' specify ''a'', and ''param[[6]'' specifies ''c''. After __lcong48()__ has been called, a subsequent call to either __srand48()__ or __seed48()__ will restore the standard values of ''a'' and ''c''.
-The initialization function __lcong48()__ allows the user
-to specify initial values for ''Xi'', ''a'' and
-''c''. Array argument elements ''param[[0-2]'' specify
-''Xi'', ''param[[3-5]'' specify ''a'', and
-''param[[6]'' specifies ''c''. After __lcong48()__
-has been called, a subsequent call to either
-__srand48()__ or __seed48()__ will restore the
-standard values of ''a'' and ''c''.
!!CONFORMING TO
+SVID 3
-
-SVID 3
!!NOTES
+These functions are declared obsolete by SVID 3, which states that rand(3) should be used instead.
-
-These functions are declared obsolete by SVID 3, which
-states that rand(3) should be used instead.
!!SEE ALSO
-
-
rand(3), random(3)
-----