      PROGRAM CAU_ADD ! Berg, Sep 15 2006.
C
C EMPIRICAL DISTRIBUTION FUNCTION AND Q-DISTRIBUTION.
C
      include '../../ForLib/implicit.sta'
      include '../../ForLib/constants.par'
c     PARAMETER(IUO=6,IUD=10,ISEED1=1,ISEED2=0,N=100)
      PARAMETER(IUO=6,IUD=10,ISEED1=1,ISEED2=0,N=10 000)
      DIMENSION DATA(N)
      LTEST=.TRUE.
      LTEST=.FALSE.
      IF(LTEST) STOP "CAU_ADD: LTEST."
C
      CALL RMASET(-1,-1,ISEED1,ISEED2,'ranmar.d')
      XMIN=-10*ONE
      XMAX=+10*ONE
C
      DO I=1,N
        CALL RMACAU(DATA(I))
      END DO
      CALL HEAPSORT(N,DATA)
      CALL QDF_GNU(IUD,N,DATA)
C
      DO I=1,N
        CALL RMACAU(X1)
        CALL RMACAU(X2)
        DATA(I)=X1+X2
      END DO
      CALL HEAPSORT(N,DATA)
      CALL QDF_GNU(IUD,N,DATA)
C
      SQ2=SQRT(TWO)
      DO I=1,N
        CALL RMACAU(X1)
        CALL RMACAU(X2)
        DATA(I)=(X1+X2)/SQ2
      END DO
      CALL HEAPSORT(N,DATA)
      CALL QDF_GNU(IUD,N,DATA)
C
      DO I=1,N
        CALL RMACAU(X1)
        CALL RMACAU(X2)
        DATA(I)=(X1+X2)/TWO
      END DO
      CALL HEAPSORT(N,DATA)
      CALL QDF_GNU(IUD,N,DATA)
C
      STOP
      END

      include '../../ForLib/rmaset.f'
      include '../../ForLib/ranmar.f'
      include '../../ForLib/rmacau.f'
      include '../../ForLib/heapsort.f'
      include '../../ForLib/qdf_gnu.f'
C      include '../../ForLib/qdf_gnu.f'

