       Re: Speed Up of Calculations on Large Lists

• To: mathgroup at smc.vnet.net
• Subject: [mg108958] Re: Speed Up of Calculations on Large Lists
• From: Ray Koopman <koopman at sfu.ca>
• Date: Thu, 8 Apr 2010 08:01:55 -0400 (EDT)
• References: <hpcjh0\$mva\$1@smc.vnet.net> <hphq5f\$1h6\$1@smc.vnet.net>

```On Apr 7, 4:26 am, sheaven <karg.ste... at googlemail.com> wrote:
>
> I did some testing and here is the outcome:
>
> [...]
>
> Drop is by far the fastest function

movAc is just as fast as maDropF, and its worst case
has one digit more precision than maDropF's worst case.

In:= << Developer`

In:= movAc[data_, days_] :=
Accumulate[
Prepend[Drop[data, days] - Drop[data, -days],
Tr@Take[data, days]]]/days

Function[{vData, days},
With[{vAcc = Prepend[Accumulate@vData, 0.]},
ToPackedArray[(Drop[vAcc, days] - Drop[vAcc, -days])/days,
Real]]];

In:= PackedArrayQ[
data = 100 + Accumulate[RandomReal[{-1, 1}, {1*^4}]] ]

Out= True

In:= AbsoluteTiming[
m0 = Table[MovingAverage[data, days], {days, 30, 250}];]

Out= {1.500583, Null}

In:= AbsoluteTiming[
m1 = Table[movAc[data, days], {days, 30, 250}];]
{m1 == m0, Max@Abs[m1/m0 - 1]}

Out= {0.792954, Null}
Out= {False, 1.60982*10^-14}

In:= AbsoluteTiming[
m2 = Table[maDropF[data, days], {days, 30, 250}];]
{m2 == m0, Max@Abs[m2/m0 - 1]}

Out= {0.820129, Null}
Out= {False, 1.93734*10^-13}

```

• Prev by Date: Re: Inverse Laplace Transform
• Next by Date: proper supremum norm implementation
• Previous by thread: Re: Speed Up of Calculations on Large Lists
• Next by thread: Re: Speed Up of Calculations on Large Lists