MathGroup Archive 2007

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

Search the Archive

Re: is there a better way to iterate this?


On Jun 18, 4:19 am, dan siegal-gaskins <dantimat... at gmail.com> wrote:
> ... all that's really important is that listA and listB
> are lists of 21 sublists, and each sublist has 18 elements.

I should have wrapped N around the right hand sides of a & b, and you
should have said sooner that all the sublists have the same length.
This will be faster:

c = Outer[Dot, N[#/Norm@Flatten@#]&[listA - Mean@Flatten@listA],
               N[#/Norm@Flatten@#]&[listB - Mean@Flatten@listB], 1];
bar = Table[ Total@Extract[ c, Transpose@{Range@21,
             Ordering@Table[Random[],{21}]} ], {1*^5}]

Here's one way to look at the distribution:

With[{n = Length@bar, m = Mean@bar},
ListPlot[Transpose@{Sort@bar,Range[.5,n]/n}, PlotJoined->True,
Frame->True, AxesOrigin->{m,.5}]; {m,StandardDeviation@bar}]



  • Prev by Date: Re: A question about RegionFunction in ver. 6.0
  • Next by Date: Re: Re: FFT of the piecewise step function
  • Previous by thread: Re: is there a better way to iterate this?
  • Next by thread: Re: is there a better way to iterate this?