Am 24.10.2017 um 15:38 schrieb Sven Schreiber:
[moving this to devel now]
Am 24.10.2017 um 15:13 schrieb Artur Tarassow:
> Am 24.10.2017 um 14:36 schrieb Sven Schreiber:
>> Because each call to randgen1() should be giving you a new random
>> number, if you know what I mean. In the original code (now in
>> SBslow()) this looks different.
>
> Good point, Sven. I was also thinking about the purpose for the 2nd
> draw. It's actually taken from K. Sheppard's code.
Please show us. From a quick look at what he has online it didn't seem
to me that way.
Please look at slide 34:
https://www.kevinsheppard.com/images/6/64/AFE_Week_1_handout.pdf
> Are there any theoretical points on this? Of course drawing
another
> time costs computational time...
Well it's quite a different thing. And yes, a side effect is more
computational effort.
> Yes, we have to call SB() each time. I guess that incorporating the
> MC-part (calling SB many times) into the function environment could
> speed up things due to reduced transfer costs (copy/return).
As I said, by using the 'const' declaration most of the copy should be
gone I'd hope.
The 'const' declaration does not change (or maybe only marginally)
computational time in my examples even if the vector has 10000 rows.
> its current form, SB() is very flexible and not limited to some
> specific purpose (some specific time-series model or so).
Well, you could add an optional argument 'numdraws' or something. If
numdraws==1 (the default) everything stays as it is now. Otherwise you
return a matrix with the number of columns equal to numdraws. This might
save you some function call overhead.
That's a good point. Let me experiment with this.
> Still, the MATLAB example shares the same architecture and is so
much
> faster.
Yes, it is an interesting comparison in any case. Maybe Matlab is doing
some just-in-time compilation, don't know.
True, JIT might be one reason.
Artur