MathGroup Archive 2006

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

Search the Archive

Re: Count Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65521] Re: [mg65501] Count Function
  • From: János <janos.lobb at yale.edu>
  • Date: Thu, 6 Apr 2006 06:52:04 -0400 (EDT)
  • References: <200604051055.GAA21742@smc.vnet.net> <55DC5ED6-AB89-4A5A-B93F-694BAD259CF6@yale.edu> <04811363-653A-423F-8283-C2FF31B1BAD2@videotron.ca>
  • Sender: owner-wri-mathgroup at wolfram.com

Gregory,

As I see, Count wants a form or a pattern describing the appearance  
of an element or the element be in a Wolfram defined domain.  I do  
not see how a criteria like being bigger than -9 can be encapsulated  
into an appearance.  When you do Count[xx[[All,14]],-9.] it is giving  
you NOT who  EQUALs to -9 but rather who LOOKs LIKE -9.  For me that  
is two different things.

Of course it does not mean that someone else cannot do it :)

Here is my second newbie approach, in this case using Count:

Count[(#1 > 9 & ) /@
    xmat[[All,14]], True]

It is still a combo.  It is a little slower for small lists then the  
Length[Select[...]] combo.

With the best,

János

On Apr 5, 2006, at 1:00 PM, Gregory Lypny wrote:

> Thanks János,
>
> That would be my natural inclination: to combine two functions,  
> Length and Select in this case, to get  a result that serves as a  
> check of whatever I'm able to hammer out directly using something  
> like Count.
>
> 	Regards,
>
> 		Gregory
>
> On Wed, Apr 5, 2006, at 12:47 PM, János wrote:
>
>>
>> On Apr 5, 2006, at 6:55 AM, Gregory Lypny wrote:
>>
>>> The syntax will be the death of me.
>>>
>>> Count[X[[All,14]], -9.] will tally how many elements in column 14 of
>>> matrix X are equal to -9, but I can't for the life of me figure out
>>> how to get how many are greater than -9.  Any hint would be most
>>> appreciated.
>>>
>>> 	Greg
>>>
>>
>> Here is a newbie approach:
>>
>> In[1]:=
>> xmat = Table[Table[
>>     Random[Integer,
>>      {1, 100}], {i, 1, 20}],
>>    {j, 1, 30}]
>>
>>
>> In[6]:=
>> Length[Select[xmat[[All,14]],
>>    #1 > 9 & ]]
>> Out[6]=
>> 25
>>
>>
>> János
>>
>>
>> ----------------------------------------------
>> Trying to argue with a politician is like lifting up the head of a  
>> corpse.
>> (S. Lem: His Master Voice)
>>



----------------------------------------------
Trying to argue with a politician is like lifting up the head of a  
corpse.
(S. Lem: His Master Voice)


  • References:
  • Prev by Date: Re: Lost Values after For[ ] loop
  • Next by Date: Re: Re: simplify a trig expression
  • Previous by thread: Re: Count Function
  • Next by thread: Re: Count Function