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)
113 REAL av,var,xmax,xmin
132 IF (x(i).LT.xmin) xmin = x(i)
133 IF (x(i).GT.xmax) xmax = x(i)
138 sum = sum + (x(i)-av)**2
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)
ColumnVector real(const ComplexColumnVector &a)
subroutine genmn(parm, x, work)
octave_int< T > xmin(const octave_int< T > &x, const octave_int< T > &y)
octave_int< T > xmax(const octave_int< T > &x, const octave_int< T > &y)
subroutine phrtsd(phrase, seed1, seed2)
subroutine setall(iseed1, iseed2)
subroutine setgmn(meanv, covm, ldcovm, p, parm)
subroutine prcomp(p, mean, xcovar, ldxcov, answer)
subroutine setcov(p, var, corr, covar, ldcov)
real function onecov(x, y, n)
subroutine stat(x, n, av, var, xmin, xmax)