On 08/20/2012 04:49 PM, Riccardo (Jack) Lucchetti wrote:
On Mon, 13 Aug 2012, Allin Cottrell wrote:
> On Mon, 13 Aug 2012, Logan Kelly wrote:
>
>> Is there a cumulative product command similar to the
>> cumulative sum command cum?
>
> Not built-in, but it's trivial to write.
>
> <hansl>
> function series cumprod (series y)
> y = y * y(-1)
> return y
> end function
> </hansl>
Beware the power of logarithms!
<hansl>
nulldata 10
fact = exp(cum(ln(index)))
print index fact -o </hansl>
Completely non-important, but I wonder which is more efficient --
exp(...ln()) seems very costly in terms of complicated nonlinear
function evaluations, but OTOH there's the function call overhead in the
user-defined function...
Of course I could just test myself... oh well.
-sven