On Wed, 20 Feb 2013, Riccardo (Jack) Lucchetti wrote:
On Tue, 19 Feb 2013, Allin Cottrell wrote:
>> Mmmm. I like it. This as a native function would be very nice to have.
>> Plus, this is one of those cases in which C would be much much faster than
>> hansl.
>
> Agreed. In tonight's CVS we have a native function, aggregate(), on the
> pattern shown above, which supports the methods sum, mean, sd, var, sst,
> skewness, kurtosis, min, max, median and gini. It'll be in the snapshots
> tomorrow.
Very nice. The next step, logically, would be to support user-written
functions too. However, this would mean to complicate the code by a factor (I
reckon) of 1 to 5 or so.
I was afraid the factor might be at the top end of that range,
but I experimented and it's more like 0.25. So user-functions
are now supported. The function must take a single series
argument and return a scalar. Example:
<hansl>
function scalar my_aggregator (series x)
return sum(x^3)
end function
open credscore.gdt
matrix m = aggregate(Income, Acc, my_aggregator)
print m
</hansl>
Allin