Monte Carlo methods: Difference between revisions
Content added Content deleted
Line 610: | Line 610: | ||
end program |
end program |
||
function pi( |
function pi(n) |
||
integer |
integer :: n |
||
real(8) |
real(8) :: x(2,n),pi |
||
real(8) :: pi |
|||
call random_number(x) |
call random_number(x) |
||
pi = 4.d0 * dble( count( hypot(x(1,:),x(2,:)) <= 1.d0 ) ) / n |
|||
pi = 4.d0 * dble( count( hypot(x(1,:),x(2,:)) <= 1.d0 ) ) / nsamples |
|||
end function |
end function |
||
</lang> |
</lang> |