      program ransu_dosu_bunpu                 ! ex060203.f
      parameter( Nr=10000, Nx=100, Nx1=Nx+1 )
      real*8 r, dx, x(Nx1), Box(Nx), BoxP(Nx)
      common /comransu/iy
      save   /comransu/
      data Box / Nx*0d0 /
c     data iy / 1234567 /
      iy = 1234567
      dx  = (1.0-0.0)/Nx
      x(1)= 0
      do j=1,Nx
        x(j+1) = x(j) + dx
      enddo

      do i=1,Nr
        call ransu( r )
!       write(*,*) i, iy, r
        do j=1,Nx
          if( x(j).lt.r .and. r.le.x(j+1) ) then
            Box(j) = Box(j) + 1
            go to 100
          endif
        enddo
  100   continue
      enddo
 
!     write(*,*) 'Number'
!     do j=1,Nx
!       write(*,'(1p3e12.4)') x(j), x(j)+dx/2, Box(j)
!     enddo

      do j=1,Nx
        BoxP(j) = Box(j) / dx / Nr
      enddo

!     write(*,*) 'Probability'
!     do j=1,Nx
!       write(*,'(1p3e12.4)') x(j), x(j)+dx/2, BoxP(j)
!     enddo

      open(1, file = 'ex060203.dat' )
      do j=1,Nx
        write(1,'(1p4e12.4)') x(j), x(j)+dx/2, Box(j), BoxP(j)
      enddo
      close(1)

      stop
      end
