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)
CALL RN2DIM(X,Y,XLONG)
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.