(file) Return to gauss1.f CVS log (file) (dir) Up to [HallC] / Poltar

 1 jones 1.1 	real*8 function gauss1(nsigmax)
 2           
 3           **************************************************************************
 4           * This subroutine generates a random number distributed about a Gaussian
 5           * centered at zero with a standrd deviation of 1.  The gaussian is
 6           * truncated at nsigmax.  Use as a function like: VAL' = VAL + WIDTH*X
 7           *
 8           * Algorithm is from PHYSICS LETTERS B V.204, P.83 ''Review of particle
 9           * properties", Particle Data Group. (with nsigmax cutoff added).
10           **************************************************************************
11           
12           	implicit none
13           
14           	real*8 u1,u2,v1,v2,s,nsigmax
15           	real*8 grnd
16           
17           1	u1 = grnd()
18           	u2 = grnd()
19           	v1 = 2.0*u1-1.0
20           	v2 = 2.0*u2-1.0
21           	s  = v1**2+v2**2
22 jones 1.1 
23           	if (s.gt.1. .or. s.eq.0) goto 1
24           
25           	gauss1 = v1*sqrt(-2.*log(s)/s)  ! <--want a natural log here
26           
27           	if (abs(gauss1).gt.nsigmax) goto 1	!truncate at nsigmax
28           
29           	return
30           	end

Analyzer/Replay: Mark Jones, Documents: Stephen Wood
Powered by
ViewCVS 0.9.2-cvsgraph-1.4.0