Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  montecarlo
Language: FORTRAN
Code:
     program montecarlo
     implicit none
     integer:: i,j
     real:: I1=0.33,I2=0.33, I3=0.35, y, x,a1=2, a2=1.5, a3=4.5
     real,dimension(2000):: t


     open(10, file='data',status="replace", action="write")
     do i=1,2000
     CALL RANDOM_NUMBER(x)
     CALL RANDOM_NUMBER(y)
     if (x<I1) then
     t(i)=(-1/a1)*log(y)
     else if (I1<x .AND. x<(I1+I2)) then 
     t(i)=(-1/a2)*log(y)
     else if ((I1+I2)<x .AND. x<(I1+I2+I3)) then 
     t(i)=(-1/a3)*log(y)
     end if
     write(10,*)t(i)
     print*, t(i)
     end do
        
         end program



          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
Comments: