[Rd] Improvement of SignRank functions

Martin Maechler maechler at stat.math.ethz.ch
Sat Dec 15 12:29:34 CET 2007


Hi Ivo,

>>>>> "IU" == Ivo Ugrina <ivo at iugrina.com>
>>>>>     on Fri, 14 Dec 2007 23:03:37 +0100 writes:

    IU> I took some time and liberty and tried to improve
    IU> existing implementation of SignRank functions
    IU> in R. (dsignrank, ...)

    IU> As I have seen they've been based on csignrank.
    IU> So I modified csignrank and, I believe,
    IU> improved calculation time and memory efficiency.

do you have evidence for your belief?
i.e. a set of  system.time(.) calls where you see the
difference?

    IU> The idea is basically the same. I use the same recursion
    IU> as original author 

 (Kurt Hornik)

    IU> used with one slight modification.
    IU> I am generating Wilcoxon SignRank density from the
    IU> beginning (for n=2,3,...) with the help of recursion formula.

    IU> What is changed?
    IU> There is no need for SINGRANK_MAX in src/nmath/nmath.h anymore.

    IU> Only functions:
    IU> static void w_free()
    IU> void signrank_free()
    IU> static void w_init_maybe(int n)
    IU> static double csignrank(int k, int n)
    IU> in src/nmath/signrank.c have been altered.
    IU> There was no change to dsignrank, psignrank, ...

    IU> I've tried to make as little changes as possible.

    IU> So, to compile with new functions only src/nmath/signrank.c
    IU> needs to be changed with the one given in attachment.

    IU> I hope it really is an improvement.

Me too :-)     {Waiting for your test results}

The code does look slightly simpler, I agree.

BTW: If you had a smart idea to *not* use a static 'w' and still
     be memory efficient,
     that could lead to make that code "thread-safe", but I am
     not at all sure this is possible without using
     "thread-library C code".

Martin



More information about the R-devel mailing list