next up previous index
Next: V135 Gamma or Up: CERNLIB Previous: V122 Correlated Gaussian-distributed

V130 Random Three-Dimensional Vectors

Routine ID: V130
Author(s): F. JamesLibrary: MATHLIB
Submitter: Submitted: 15.09.1978
Language: FortranRevised:

RAN3D generates random vectors, uniformly distributed over the surface of a sphere of a given radius.

Structure:

SUBROUTINE subprogram
User Entry Names: RAN3D
External References: NRAN (V105)

Usage:

    CALL RAN3D(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).

Method:

A random vector in the unit cube is generated using NRAN (V105) and is rejected if it lies outside the unit sphere. 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.

V135


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995