FW: [R] Optimising code

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Oct 7 12:18:23 CEST 2003


Crispin Miller wrote:

>>>I have a function that applies a wilcoxon test to 12 sets of about a quarter of a million pairs
> 
> 
>>... and let me guess: everything is significiant to an almost arbitrary 
>>value of \alpha?
> 
> 
> :-) For each of quarter of a million sets, I do a wilcoxon between two pairs each containing twenty numbers...
> I do this 12 times...

Ah. Sorry for misunderstanding.


>>>(and takes about 3 hours). I've replaced the inner loop I 
>>
>>had originally with a function call via mapply, and also 
>>considered different approximations  of the wilcoxon, rather 
>>than that which is implemented in wilcox.test, but that makes 
>>little difference 9and if anything slows things down :-).
>>
>>Are you using wilcox.test(), or a self written function?
>>
> 
> 
> I started off with wilcox.test, and tried to speed it up by hacking out as much from the original function as possible, since a fair proportion of the code being executed was logic deciding between the different flavours of the test (I didn't expect that to make much difference, but tried it anyway), there was also a call to pnorm() which I replaced with a numeric approximation. This is not inlined into the original function.


In that case you cannot do very much except for writing it in a language 
like C / Fortran, if you really need the speed.

Uwe Ligges

> Crispin
>  
> --------------------------------------------------------
> 
>  
> This email is confidential and intended solely for the use o...{{dropped}}
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list