Re: Counting list elements above/below a given value
- To: mathgroup at smc.vnet.net
- Subject: [mg17268] Re: [mg17202] Counting list elements above/below a given value
- From: Clemens Frey <btml01 at uni-bayreuth.de>
- Date: Fri, 30 Apr 1999 02:34:48 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Dear Bill, since Count expects a pattern as a second argument (and not a criterion like Select, e.g.) , try something like this: lst = Table[Random[],{10000}]; Count[lst, x_ /; x>0.5] Here a conditional pattern is used. Hope this helped Clemens ------------------------------------------------------------ Clemens Frey Post-Graduate Student/Doctoral Candidate Department of Mathematics/BITOEK University of Bayreuth(Germany) clemens.frey at uni-bayreuth.de http://www.bitoek.uni-bayreuth.de/~Clemens.Frey ------------------------------------------------------------ On Mon, 26 Apr 1999, W.W. Sampson wrote: > I wish to count the number of elements within a list above > a given value. I can do this using the following: > > Length[Select[Flatten[listname], value > #1&]] > > However, my list is a 280 x 280 matrix and consequently > this takes a while to evaluate. My guess is that there > must be something more efficient. I've tried: > > Count[listname, value > #1&] > > but the output given is 0, which I know to be incorrect. > > Any ideas appreciated. > > Bill >