		Subroutine Correrror(Iseed,Nchan,Gamma,CNoise)

		Integer Iseed	! seed for random number generator, goes both ways
		Integer Nchan	! number of channels
		Real Gamma(Nchan,Nchan) ! the magic gamma multiplier
		Real CNoise(Nchan)		! generated correlated noise

		Real Mean/0.0/, Var/1.0/
		Integer Ichan
		Real Noise(50)  ! make sure this is dimensioned to at least Nchan

		 do ichan = 1 , nchan
		  call normal_random(Iseed,mean,var,noise(Ichan))
		 enddo
		 
		 Cnoise = matmul(gamma,noise)
		Return
		End
			SUBROUTINE NORMAL_RANDOM(ISEED,FMEAN,SIGMA,RANDOM)
!************************************************************************
!*									                                    *
!*	Module Name:	NORMAL_RANDOM					                    *
!*									                                    *
!*	Language:	Fortran-77	   Library: [AIMS.UTILITY]	                *
!*	Version.Rev:	1.0 26 DEC 85	Programmer: KLEESPIES		        *
!*									                                    *
!*	Calling Seq:	CALL NORMAL_RANDOM(ISEED,FMEAN,SIGMA,RANDOM)	    *
!*									                                    *
!*	Description:	Computes a random number from a population of	    *
!*		random numbers with mean FMEAN and standard deviation	        *
!*		SIGMA.  This routine starts with uniformly distributed	        *
!*		random numbers on the interval [0,1] and transforms them        *
!*		to be randomly distributed with the property 		            *
!*		N(FMEAN,SIGMA).  The transformation equation is 	            *
!*									                                    *
!*		x = FMEAN + SIGMA*sqrt(-2lny1) * cos(2pi*y2)		            *
!*									                                    *
!*		where x is the transformed random variate, and y1 and	        *
!*		y2 are two random variates determined by successive 	        *
!*		calls to the intrinsic RAN routine.			                    *
!*									                                    *
!*		A discussion of this transformation may be found in the	        *
!*		text "Probability, Statistical Optics, and Data Testing"        *
!*		by B.R. Frieden (Springer-Verlag) on page 165.		            *  
!*									                                    *
!*	Input Args:	I*4 	ISEED	Seed for random number 		            *
!*			R*4	FMEAN	Mean for desired normally 	                    *
!*					distributed random variate	                        *
!*			R*4	SIGMA	Standard deviation for desired	                *
!*					normally distributed random	                        *
!*					variate.			                                *
!*									                                    *
!*	Output Args:	R*4	RANDOM	Random variate from population	        *
!*				with mean FMEAN and standard deviation	                *
!*				SIGMA.					                                *
!*									                                    *
!*	Common Blks:	none						                        *
!*									                                    *
!*	Include:	none						                            *
!*									                                    *
!*	Externals:	RAN	intrinsic random number generator	                *
!*									                                    *
!*	Data Files:	none						                            *
!*									                                    *
!*	Restrictions:	Note that ISEED is internally reset in this	        *
!*			program.  It should be initially set to some	            *
!*			large number.  A series of random numbers can	            *
!*			be generated without resetting ISEED.		                *
!*									                                    *
!*	Error Codes:	none						                        *
!*									                                    *
!*	Error Messages:	none						                        *
!*									                                    *
!************************************************************************

	INTEGER*4 ISEED
	REAL*4 FMEAN,SIGMA,RANDOM
	REAL*4 Y1,Y2
	REAL*4 TWOPI /6.283185308/
	REAL RAN

!	compute two random variates

  100   CONTINUE

	Y1 = RAN(ISEED)

!	check for zero value (we can't very well go about trying to
!	take the natural log of zero now can we?)

	IF(Y1 .EQ. 0.0) GO TO 100

	Y2 = RAN(ISEED)

	RANDOM = FMEAN + SIGMA*SQRT(-2.0*LOG(Y1))*COS(TWOPI*Y2)

	RETURN
	END

