MathGroup Archive 2006

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

Search the Archive

Re: Count Function


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}


  • Prev by Date: Problem with the Hannan Rissanen procedure
  • Next by Date: Mathematica for Mathematics Education
  • Previous by thread: Re: Count Function
  • Next by thread: Re: Count Function