Hi All,

I have a bottleneck in my programs which is related to my use of ;. .
Does anyone have any advice on how I could change my data structure or
my usage of ;. to speed things up?

I am storing all of my time series (which I have aligned) in a 2x2
matrix where each row is a different series and each column is a
different day. So for me a shape 400 10000 array is 400 time series
with 10000 days each.

I am applying a moving time window of fixed duration over the series
and applying a function on the data inside the window using ;. .

The example below is generates sample data as i.400 10000 and adds up
the numbers in a window of duration 25 days.

ts '; (1 1,:400,25)    (+/@:;);._3  (i. 400 20000)'
1.90589 6.91929e7

I can get a small speed up by rotating the input matrix:
ts '; (1 1,:25,400)    (+/@:;);._3  (|: i. 400 20000)'
1.69103 1.02748e8

I can get another small speed up by using , instead of ; :
ts '; (1 1,:25,400)    (+/@:,);._3  (|: i. 400 20000)'
0.614452 1.05468e8

Is there a way to speed this up further by changing the way I am
representing the data or any in any other way? Maybe ;. is not the
best way to do this?

Thanks,
Matthew.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to