In setting up some simulations I was surprised at the speed of some computations. For example, consider:
The results are:
Does anyone have insights into why rnormal() is about 50% slower than invnormal(runiform()) in this example?
Code:
mata
time()
for (j=1;j<=50000;j++) {
z=rnormal(10000,1,0,1)
}
time()
for (j=1;j<=50000;j++) {
z=invnormal(runiform(10000,1))
}
time()
end
Code:
:
: time()
08:15:54 25 Apr 2022
:
: for (j=1;j<=50000;j++) {
> z=rnormal(10000,1,0,1)
> }
:
: time()
08:16:17 25 Apr 2022
:
: for (j=1;j<=50000;j++) {
> z=invnormal(runiform(10000,1))
> }
:
: time()
08:16:33 25 Apr 2022
:
: end

Comment