40 SUBROUTINE prcomp(p,mean,xcovar,ldxcov,answer)
46 REAL mean(p),xcovar(ldxcov,p),rcovar(maxp,maxp)
47 REAL answer(1000,maxp)
50 REAL rmean(maxp),rvar(maxp),
onecov
52 parameter(maxobs=1000)
55 CALL
stat(answer(1,i),maxobs,rmean(i),rvar(i),dum1,dum2)
56 WRITE (*,*)
' Variable Number',i
57 WRITE (*,*)
' Mean ',mean(i),
' Generated ',rmean(i)
58 WRITE (*,*)
' Variance ',xcovar(i,i),
' Generated',rvar(i)
60 WRITE (*,*)
' Covariances'
63 WRITE (*,*)
' I = ',i,
' J = ',j
66 rcovar(i,j) =
onecov(answer(1,i),answer(1,j),maxobs)
67 WRITE (*,*)
' Covariance ',xcovar(i,j),
' Generated ',
79 SUBROUTINE setcov(p,var,corr,covar,ldcov)
88 REAL covar(ldcov,p),var(p)
99 IF (.NOT. (i.EQ.j)) go to 10
103 10 covar(i,j) = corr*
sqrt(var(i)*var(j))
111 SUBROUTINE stat(x,n,av,var,xmin,xmax)
158 parameter(maxobs=1000)
165 INTEGER i,iobs,is1,is2,j,p
171 REAL answer(1000,maxp),ccovar(maxp,maxp),covar(maxp,maxp),
172 + mean(maxp),param(500),temp(maxp),var(maxp),work(maxp)
181 +
' Tests Multivariate Normal Generator for Up to 10 Variables'
183 +
' User inputs means, variances, one correlation that is applied'
184 + /
' to all pairs of variables'/
185 +
' 1000 multivariate normal deviates are generated'/
186 +
' Means, variances and covariances are calculated for these.'
189 10
WRITE (*,*)
'Enter number of variables for normal generator'
191 WRITE (*,*)
'Enter mean vector of length ',p
192 READ (*,*) (mean(i),i=1,p)
193 WRITE (*,*)
'Enter variance vector of length ',p
194 READ (*,*) (var(i),i=1,p)
195 WRITE (*,*)
'Enter correlation of all variables'
198 CALL
setcov(p,var,corr,covar,maxp)
199 WRITE (*,*)
' Enter phrase to initialize rn generator'
200 READ (*,
'(a)') phrase
201 CALL
phrtsd(phrase,is1,is2)
208 ccovar(i,j) = covar(i,j)
215 CALL
setgmn(mean,ccovar,maxp,p,param)
216 DO 40,iobs = 1,maxobs
217 CALL
genmn(param,work,temp)
219 answer(iobs,j) = work(j)
223 CALL
prcomp(p,mean,covar,maxp,answer)