V131: Random Two- and Three-Dimensional Vectors

Author(s): F. James Library: MATHLIB
Submitter: Submitted: 22.04.1996
Language: Fortran Revised:

RN3DIM generates random vectors, uniformly distributed over the surface of a sphere of given radius.
RN2DIM generates random vectors, uniformly distributed over the circumference of a circle of given radius.

Structure:

SUBROUTINE subprogram
User Entry Names: RN2DIM, RN3DIM
External References: RANLUX

Usage:

    CALL RN3DIM(X,Y,Z,XLONG)
X,Y,Z
(REAL) A random 3-dimensional vector of length XLONG.
XLONG
(REAL) Length of the vector (to be specified on entry).
    CALL RN2DIM(X,Y,XLONG)
X,Y
(REAL) A random 2-dimensional vector of length XLONG.
XLONG
(REAL) Length of the vector (to be specified on entry).

Method:

A random vector in the unit cube is generated using RANLUX (V115) and is rejected if it lies outside the unit sphere. In the case of RN3DIM, this rejection technique uses on average about 6 random numbers per vector, where only two are needed in principle. However, it is faster than the classical two-number technique which requires a square root, a sine, and a cosine.
tex2html_wrap_inline65


Michel Goossens Wed Jun 5 08:44:35 METDST 1996