Re: Conditions with Statistical Functions
- To: mathgroup at smc.vnet.net
- Subject: [mg66169] Re: Conditions with Statistical Functions
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Tue, 2 May 2006 02:43:44 -0400 (EDT)
- References: <16568608.1146308002406.JavaMail.root@eastrmwml01.mgt.cox.net> <e31vb8$hgd$1@smc.vnet.net> <4454EC45.8030009@gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Thanks again, Jean-Marc. This is elegant. As I mentioned before, I'm facing an uphill battle with Mathematica's syntax, and in particular, the meaning and placement of things like #, #1, or #[[1]], &, @, @@, @@@, /@, /. . It's all a bit overwhelming! I think I understand your second version better, so I'll work with it first. If I'm not mistaken, /@ tells the Mean function to map over its argument and #1 directs that mapping to the first argument, which for Mean applied to a matrix is a vector. What I never would have gotten on my own is the use of the second ampersand in parenthesis. Is that meant to connect Select with Transpose? I'm also not quite clear on why we need Transpose because Mean operates on columns anyway. Regards, Greg On Sun, Apr 30, 2006, at 12:56 PM, Jean-Marc Gulliet wrote: > In[3]:= > Mean /@ (Transpose[lst /. x_ /; x <= 100 -> 0] /. > 0 -> Sequence[]) > > Out[3]= > 1311 1450 527 > {125, ----, ----, ---} > 8 9 3 > > In[4]:= > Mean /@ (Select[#1, #1 > 100 & ] & ) /@ Transpose[lst] > > Out[4]= > 1311 1450 527 > {125, ----, ----, ---} > 8 9 3 > > Best regards, > Jean-Marc