      program debtopt
      implicit real*8(a-h,o-z)
      double precision cumnorm(625,2),smple(150)
      common /normdta/ cumnorm,ncum
      open(unit=19,file='CumNorm.dta')
      ndraw=150
      ncum=607
C----------------------------------------------------------------------C
C Load initial values - Normal Cumulative Distribution                 C
C----------------------------------------------------------------------C
      do 10 i=1,ncum
        read(19,9999) idum,(cumnorm(i,j),j=1,2)
   10 continue
C----------------------------------------------------------------------C
C Draw the sample of normal random variables                           C
C----------------------------------------------------------------------C
      do 50 i=1,ndraw
   25   call rndnorm(znorm)
        if(znorm.lt.-3.50.or.znorm.gt.3.50) goto 25
        smple(i) = 0.05 + 0.03*znorm
   50 continue
C----------------------------------------------------------------------C
C Compute the mean and variance of the distribution                    C
C----------------------------------------------------------------------C
      xopt = 0.0
      do 75 i=1,ndraw
        if(smple(i).lt.0.03) then
           xopt = xopt + (smple(i)-0.03)/real(ndraw)
        else
           xopt = xopt + 0.03/real(ndraw)
        endif
   75 continue
      write(6,9998) xopt
 9998 format(x,10f8.4)
 9999 format(x,i5,f8.4,x,f8.4)
      end

