      PROGRAM TEMP
      IMPLICIT NONE
      REAL      MEAN(0:30,0:7), SIGMA(0:30,0:7)
      INTEGER   HISTO(0:30,0:7,-100:100)
      REAL      LEAK(0:30,0:7)
      INTEGER   I, J, TOTAL, RATIO
      INTEGER   ANAL_1, DIGI_1, ANAL_2,
     &          DIGI_2, ANAL_SUM, DIGI_SUM, SUM_DIGI
      PARAMETER ( ANAL_1=1, ANAL_2=2, ANAL_SUM=3,
     &          DIGI_1=4, DIGI_2=5, DIGI_SUM=6, SUM_DIGI=7 )
      REAL      NORM_1, NORM_2
      REAL      PICK_2
      INTEGER   DIGITIZED_PICK_2

      TOTAL = 100000


      DO I = 0 , 7
        DO RATIO = 0 , 30
          SIGMA (RATIO,I) = 0
          MEAN (RATIO,I) = 0
          DO J = -100 , 100
            HISTO (RATIO,I,J) = 0
          ENDDO
        ENDDO
      ENDDO


      DO I = 1 , TOTAL

        CALL RANNOR ( NORM_1, NORM_2 )

        DO RATIO  =  0 , 30

          PICK_2 = NORM_2 * (RATIO/10.0)
          DIGITIZED_PICK_2 = NINT ( PICK_2 )

          IF ( ABS(DIGITIZED_PICK_2) .LE. 100 )
     &      HISTO(RATIO,DIGI_2,DIGITIZED_PICK_2) =
     &             HISTO(RATIO,DIGI_2,DIGITIZED_PICK_2) 
     &           + 1

          MEAN(RATIO,ANAL_SUM) = MEAN(RATIO,ANAL_SUM) + PICK_2
          SIGMA(RATIO,ANAL_SUM)=SIGMA(RATIO,ANAL_SUM) + PICK_2 **2

          MEAN(RATIO,DIGI_2) = MEAN(RATIO,DIGI_2)+  DIGITIZED_PICK_2
          SIGMA(RATIO,DIGI_2)= SIGMA(RATIO,DIGI_2)+ DIGITIZED_PICK_2**2

        ENDDO
      ENDDO


      DO RATIO  =  0 , 30

        DO I = 1 , 7
          MEAN (RATIO,I) = MEAN (RATIO,I) / FLOAT(TOTAL)
          SIGMA (RATIO,I) = SIGMA (RATIO,I) / FLOAT(TOTAL)
          SIGMA (RATIO,I) = SIGMA (RATIO,I) - MEAN (RATIO,I) **2
          SIGMA (RATIO,I) = SQRT(SIGMA (RATIO,I) )
        ENDDO

        DO J =  NINT(2.5*SIGMA(RATIO,ANAL_SUM)), 100
          LEAK(RATIO,DIGI_2) = LEAK(RATIO,DIGI_2) 
     &                       + HISTO(RATIO,DIGI_2,J)
        ENDDO

        LEAK(RATIO,DIGI_2) = 100.0 * LEAK(RATIO,DIGI_2) / TOTAL

        WRITE ( 6,  2000, ERR=90 ) (RATIO/10.0),
     &                              SIGMA(RATIO,ANAL_SUM),
     &                              NINT(2.5*SIGMA(RATIO,ANAL_SUM)),
     &                              SIGMA (RATIO,DIGI_2),
     &                              LEAK (RATIO,DIGI_2),
     &                            ( SIGMA(RATIO,DIGI_2)**2
     &                            / ( SIGMA(RATIO,ANAL_SUM)**2
     &                              + 1.0/12.0 ) )

 2000   FORMAT ( ' ', 2F5.2, I3, 10F8.3 )
   90   CONTINUE

      ENDDO

      END

SET WINDOW X FROM 1 TO 8 Y FROM 1 TO 8
SET ORDER X DUMMY DUMMY Y DUMMY DUMMY
  0.00 0.00  0   0.000 100.000   0.000
  0.10 0.10  0   0.000 100.000   0.000
  0.20 0.20  1   0.109   0.602   0.097
  0.30 0.30  1   0.309   4.792   0.549
  0.40 0.40  1   0.461  10.630   0.874
  0.50 0.50  1   0.571  15.941   0.978
  0.60 0.60  2   0.665   0.602   0.997
  0.70 0.70  2   0.758   1.581   1.003
  0.80 0.80  2   0.852   3.053   1.002
  0.90 0.90  2   0.944   4.792   0.998
  1.00 1.00  3   1.040   0.602   0.997
  1.10 1.10  3   1.137   1.108   1.000
  1.20 1.20  3   1.236   1.856   1.003
  1.30 1.30  3   1.332   2.711   1.001
  1.40 1.40  4   1.430   0.602   1.001
  1.50 1.50  4   1.528   0.939   1.000
  1.60 1.60  4   1.626   1.414   1.000
  1.70 1.70  4   1.725   1.960   1.000
  1.80 1.80  5   1.822   0.602   0.999
  1.90 1.90  5   1.922   0.874   1.000
  2.00 2.00  5   2.022   1.186   1.001
 JOIN  

NEW FRAME
SET WINDOW X FROM 1 TO 8 Y FROM 1 TO 8
SET ORDER X DUMMY DUMMY DUMMY DUMMY Y 
  0.00 0.00  0   0.000 100.000   0.000
  0.10 0.10  0   0.000 100.000   0.000
  0.20 0.20  1   0.109   0.602   0.097
  0.30 0.30  1   0.309   4.792   0.549
  0.40 0.40  1   0.461  10.630   0.874
  0.50 0.50  1   0.571  15.941   0.978
  0.60 0.60  2   0.665   0.602   0.997
  0.70 0.70  2   0.758   1.581   1.003
  0.80 0.80  2   0.852   3.053   1.002
  0.90 0.90  2   0.944   4.792   0.998
  1.00 1.00  3   1.040   0.602   0.997
  1.10 1.10  3   1.137   1.108   1.000
  1.20 1.20  3   1.236   1.856   1.003
  1.30 1.30  3   1.332   2.711   1.001
  1.40 1.40  4   1.430   0.602   1.001
  1.50 1.50  4   1.528   0.939   1.000
  1.60 1.60  4   1.626   1.414   1.000
  1.70 1.70  4   1.725   1.960   1.000
  1.80 1.80  5   1.822   0.602   0.999
  1.90 1.90  5   1.922   0.874   1.000
  2.00 2.00  5   2.022   1.186   1.001
 JOIN 

NEW FRAME
SET WINDOW X FROM 1 TO 8 Y FROM 1 TO 8
SET SYMBOL 1O
SET ORDER X  dummy dummy dummy Y 
(  0.00 0.00  0   0.000 100.000   0.000)
(  0.10 0.10  0   0.000 100.000   0.000)
  0.20 0.20  1   0.109   0.602   0.097
  0.30 0.30  1   0.309   4.792   0.549
  0.40 0.40  1   0.461  10.630   0.874
  0.50 0.50  1   0.571  15.941   0.978
  0.60 0.60  2   0.665   0.602   0.997
  0.70 0.70  2   0.758   1.581   1.003
  0.80 0.80  2   0.852   3.053   1.002
  0.90 0.90  2   0.944   4.792   0.998
  1.00 1.00  3   1.040   0.602   0.997
  1.10 1.10  3   1.137   1.108   1.000
  1.20 1.20  3   1.236   1.856   1.003
  1.30 1.30  3   1.332   2.711   1.001
  1.40 1.40  4   1.430   0.602   1.001
  1.50 1.50  4   1.528   0.939   1.000
  1.60 1.60  4   1.626   1.414   1.000
  1.70 1.70  4   1.725   1.960   1.000
  1.80 1.80  5   1.822   0.602   0.999
  1.90 1.90  5   1.922   0.874   1.000
  2.00 2.00  5   2.022   1.186   1.001
  2.10 2.10  5   2.121   1.581   1.001
  2.20 2.20  6   2.220   0.602   1.000
  2.30 2.30  6   2.318   0.812   1.000
  2.40 2.40  6   2.417   1.051   1.000
  2.50 2.50  6   2.516   1.348   0.999
  2.60 2.60  7   2.617   0.602   1.000
  2.70 2.70  7   2.716   0.770   1.000
  2.80 2.80  7   2.815   0.969   1.000
  2.90 2.90  7   2.913   1.215   0.999
  3.00 3.00  8   3.014   0.602   1.000
PLOT

SET AXES X ON
SET SCALE Y 5 1
SET LABELS X OFF
SET WINDOW Y FROM 8 TO 9
SET ORDER X  dummy Y dummy dummy 
  0.00 0.00  0   0.000 100.000   0.000
  0.10 0.10  0   0.000 100.000   0.000
  0.20 0.20  1   0.109   0.602   0.097
  0.30 0.30  1   0.309   4.792   0.549
  0.40 0.40  1   0.461  10.630   0.874
  0.50 0.50  1   0.571  15.941   0.978
  0.60 0.60  2   0.665   0.602   0.997
  0.70 0.70  2   0.758   1.581   1.003
  0.80 0.80  2   0.852   3.053   1.002
  0.90 0.90  2   0.944   4.792   0.998
  1.00 1.00  3   1.040   0.602   0.997
  1.10 1.10  3   1.137   1.108   1.000
  1.20 1.20  3   1.236   1.856   1.003
  1.30 1.30  3   1.332   2.711   1.001
  1.40 1.40  4   1.430   0.602   1.001
  1.50 1.50  4   1.528   0.939   1.000
  1.60 1.60  4   1.626   1.414   1.000
  1.70 1.70  4   1.725   1.960   1.000
  1.80 1.80  5   1.822   0.602   0.999
  1.90 1.90  5   1.922   0.874   1.000
  2.00 2.00  5   2.022   1.186   1.001
  2.10 2.10  5   2.121   1.581   1.001
  2.20 2.20  6   2.220   0.602   1.000
  2.30 2.30  6   2.318   0.812   1.000
  2.40 2.40  6   2.417   1.051   1.000
  2.50 2.50  6   2.516   1.348   0.999
  2.60 2.60  7   2.617   0.602   1.000
  2.70 2.70  7   2.716   0.770   1.000
  2.80 2.80  7   2.815   0.969   1.000
  2.90 2.90  7   2.913   1.215   0.999
  3.00 3.00  8   3.014   0.602   1.000
HISTO  

