next up previous index
Next: H101 Linear Optimization Up: CERNLIB Previous: G900 Random Number

G901 Random Points on a Circle or Sphere

Routine ID: G901
Author(s): H. LippsLibrary: KERNLIB
Submitter: Submitted: 01.09.1983
Language: FortranRevised: 24.06.1985

OBSOLETE

Please note that this routine has been obsoleted in CNL 215. Users are advised not to use it any longer and to replace it in older programs. No maintenance for it will take place and it will eventually disappear.
Suggested replacement: RAN3D (V130)

These subroutines generate random points uniformly distributed on the circumference of a circle ( RAN2VS and VRAN2S) or on the surface of a sphere ( RAN3VS and VRAN3S); i.e., 2- or 3-dimensional random vectors of specified length.

Structure:

SUBROUTINE subprograms
User Entry Names: RAN2VS, RAN3VS, VRAN2S, VRAN3S
External References: RANF (G900)

Usage:

    CALL RAN2VS(RADIUS,X,Y)
    CALL RAN3VS(RADIUS,X,Y,Z)
    CALL VRAN2S(RADIUS,N,X,Y,R)
    CALL VRAN3S(RADIUS,N,X,Y,Z,R)
RADIUS
( REAL) Radius of the circle (sphere), with centre at the origin, on which RAN2VS and VRAN2S ( RAN3VS and VRAN3S) will calculate one or more points.
N
( INTEGER) Number of random points required.
X,Y,Z
( REAL) On exit, these contain the Euclidean coordinates of the random point(s). In the case of VRAN2S and VRAN3S, X, Y, Z must be arrays of at least N elements.
R
( REAL) Array of at least N elements, required as working space.

Method:

RAN2VS initially computes a random point (x1,y1) uniformly distributed over the interior of the square -1 < x1,y1< +1 , using two calls to RANF (G900). If this point lies outside the unit circle x12+ y12≤1 it is discarded and the process is repeated until a point (x1,y1) lying inside the unit circle is found. The output point (X,Y) is then the projection of (x1,y1 ) from the origin onto the circumference of the specified circle.

RAN3VS proceeds similary, using a cube instead of a square.

VRAN2S and VRAN3S apply the same method to generate N points at each call.

These subroutines are based on a similar subroutine RAN3D (V130) written by F. James.

Operation Research Techniques and Management Science

H101



next up previous index
Next: H101 Linear Optimization Up: CERNLIB Previous: G900 Random Number


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