MathGroup Archive 2008

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

Search the Archive

Re: Normalize a collection of arrays on a specific column

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85930] Re: [mg85897] Normalize a collection of arrays on a specific column
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Thu, 28 Feb 2008 02:45:25 -0500 (EST)
  • References: <200802270924.EAA16008@smc.vnet.net>

Curtis Osterhoudt wrote:

>(Note: this is a re-send of a message. I haven't seen the message show up in 
>the list (or its archives), so I'm assuming it's lost in the aether. I 
>apologize if this shows up twice.)
>
>
>Hi, all,
>
>   I'm looking for a relatively efficient (read: not doing so
>element-by-element) way of taking a collection of several matrices, all of
>the same m x n dimensions (say), and normalizing all of them in
>whatever column I choose. If possible, it would be nice to extend this
>to any number of dimensions, but that's not necessary now.
>
>   For example, I'm looking for a function, "normalizeColumn[listOfLists_,
>p_]" which would normalize the pth column of all of the lists, not
>individually, but over the whole set, returning the whole set with just
>the pth column changed in each of its constituent lists.
>
>    Let dat1 = {{1,3,4}, {2,2,-5}, {1,1,1}} and dat2 = {{0, 3, 6},
>{2,1,4}, {5, 3, -5}}. Then if dat3 = {dat1, dat2}, the normalizeColumn
>function should return
>
>       normalizeColumn[dat3, 2] = {{{1, 1, 4}, {2, 1/2, -5}, {1, 0, 1}},
>{{0, 1, 6}, {2, 0, 4}, {5, 1, -5}}}.
>
>    I'm quite certain there's an easy way to do it; I should be able to do
>something analogous on several hundred, 200 x 200 matrices at the same
>time.
>
>               Best wishes, and thanks,
>                       Curtis O.
>
>
>  
>

Something like:

normalizeColumn[data_, p_] := Module[{tmp = data}, tmp[[All, All, 2]] = 
(tmp[[All, All, 2]] - 1)/2; tmp]

perrhaps?

In[149]:= normalizeColumn[{dat1, dat2}, 2]

Out[149]= {{{1, 1, 4}, {2, 1/2, -5}, {1, 0, 1}}, {{0, 1, 6}, {2, 0, 4}, 
{5, 1, -5}}}

Carl Woll
Wolfram Research


  • Prev by Date: option to fix the speed of exported avi file
  • Next by Date: Re: "Assuming"
  • Previous by thread: Normalize a collection of arrays on a specific column
  • Next by thread: Finding a continuous solution of a cubic