I am trying to use a linear filter to reduce loops and thereby increase
the speed of an existing program.  However,  while the "filter" function
(stats package) should have reduced the looping by about 30-fold, the
time to complete the program remained about the same.  This surprised
me, because I had made an analogous change to a Matlab version of the
same program using Matlab's "filter" function, and that change made the
program run about 9 times as fast.  

In R, is there another function that would be more efficient than
"filter" in the stats package?  Any advice would be appreciated, as I
would hate to see Matlab win this speed battle.

Relevant line from R code:
   
evTemp=filter(lambda*tempterm,1-lambda,method="recursive")
#lambda=scalar between 0 and 1 (representing learning rate in a
reinforcement learning model)
#tempterm=vector with from 1 to 150 elements (representing reinforcement
value data)


Thank you.

Anthony Bishara
Department of Psychology
College of Charleston
http://bisharaa.people.cofc.edu/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to