 
 
 
 
 
 
Re: Count Function
- To: mathgroup at smc.vnet.net
- Subject: [mg65555] Re: Count Function
- From: "Ray Koopman" <koopman at sfu.ca>
- Date: Fri, 7 Apr 2006 06:14:36 -0400 (EDT)
- References: <e1091t$ljd$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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
Regular readers know there had to be
something like this hiding in the weeds:
In[1]:= x = Table[Random[Integer,99],{1*^6}];
        Timing@Count[x, x_/;x>14]
        Timing@Length@Select[x,#>14&]
        Timing[SparseArray[Boole@Positive[x-14]] /.
               SparseArray[_, _, _, p_] :> Length@p[[2, 2]]]
Out[2]= {2.17 Second,849754}
Out[3]= {2.25 Second,849754}
Out[4]= {0.98 Second,849754}

