On 10.02.2018 12:06, Artur Tarassow wrote:
function void euler(int n, scalar *mn) # pointer form
scalar m = 0
loop i = 1..n -q
scalar the_sum = 0
loop while the_sum<=1 -q
m++
the_sum += randgen1(u,0,1)
endloop
endloop
mn = m/n
end function
set verbose off
clear
set stopwatch
scalar mn = 0
euler(10^7,&mn) # originally 10^8
printf "This took = %.6f sec.\n", $stopwatch
mn
You can gain at least one second with this version of euler function:
function void euler2(int n, scalar *mn) # pointer form
scalar m = 0
loop n -q
scalar the_sum = 0
loop while 1 -q
m++
the_sum += randgen1(u,0,1)
if the_sum > 1
break
endif
endloop
endloop
mn = m/n
end function
Marcin
--
Marcin Błażejowski