# [Gretl-devel] Making the programming of user defined functions easier

Mon Oct 29 08:02:28 EDT 2007

```To make the programming of user defined functions easier, I would like to

1. sampleranks() or tiedranks() or rankorder(): A function taking as input
one or two data series or matrix vectors and returning a series or matrix
vector with the sample ranks of the values in these, from smallest to
largest, with ties, i.e., equal values, resulting in ranks being averaged.

For example sampleranks(x) would rank the observations from variable x
only, while sampleranks(x,y) would rank the observations from both
variables jointly.

2. floor(): Round down to nearest integer. A complement to the current
commands ceil(), that round up to nearest integer. As int() gives just the
integer part, it gives the same value as floor() for positive values but
the values for ceil() for negative values, thus floor() is needed for
obtaining a round down to nearest integer for negative values. And floor()
is a standrad matematical function that shouldn't be absent from gretl.

3. factorial(): Taking a nonnegative integer as input, with factorial(n) =
n! Of course one can use gammafunc(n+1) instead, but factorial(n) would be
more intuitive.

4. permutation(): Taking two nonnegative integers as input, with
permutation(n,x) = n!/(n-x)!, i.e., the number of possible arrangements
when x objects are to be selected from a total of n and arranged in order.
Of course one can use gammafunc(n+1)/gammafunc(n-x+1) instead, but
permutation(n,x) is easier and more intuitive.

4. combination(): Taking two nonnegative integers as input, with
combination(n,x) = n!/x!(n-x)!, i.e., the number of possible selections
when x objects are to be selected from a total of n and order is not of
importance. Of course one can use