MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: list manipulation, mean value

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23024] Re: list manipulation, mean value
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Tue, 11 Apr 2000 23:18:41 -0400 (EDT)
  • Organization: University of Western Australia
  • References: <8cp61k$cu5@smc.vnet.net> <8crskk$29k@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Allan Hayes wrote:

> We can proceed as follows
>
> lis = { 1, 0, 2, 1, 3, 4} ;
>
> w[n_] := Partition[lis, n, 1]
>
> w[2]
>
> {{1, 0}, {0, 2}, {2, 1}, {1, 3}, {3, 4}}
>
> and go on to build up some custom code.
>
> But using the package
>
> << Statistics`DescriptiveStatistics`
>
> We can go directly to the moving averages.
>
> ma = MovingAverage[N[lis], 2]
>
> {0.5, 1., 1.5, 2., 3.5}

You can avoid the partition operation using ListConvolve. A moving average can
be
computed using

    ListConvolve[Table[1/i, {i}], lis]

> Well! However we can extend the definition of StandardDeviation to single
> element lists.
>
> Unprotect[StandardDeviation];
> StandardDeviation[{x_}] := 0;
> Protect[StandardDeviation];

So the overal code reads

    Flatten[Table[ReplaceList[ListConvolve[Table[1/i, {i}], lis],
        {x__, ___} :> StandardDeviation[{x}]], {i, Length[lis]}]]

Cheers,
    Paul



  • Prev by Date: Speeding up Inverting matrices.
  • Next by Date: Mathematica Wavelet-Explorer Question: Inverse Wavelet Transform on a subset of the coefficients
  • Previous by thread: Re: list manipulation, mean value
  • Next by thread: InequalitySolve with algebraic numbers and Simplify