RE: Counting list elements above/below a given value
- To: mathgroup at smc.vnet.net
- Subject: [mg17242] RE: [mg17202] Counting list elements above/below a given value
- From: "Jean-Marie THOMAS" <jmthomas at agat.net>
- Date: Fri, 30 Apr 1999 02:34:35 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Try this:
if
mat=Table[Random[],{280},{280}];
then evaluating
Timing at Count[Flatten@mat,_?(#>0.5&)]
I get the following result: (Pentium 150 Mhz)
{10.91 Second,39224}
which sounds quite reasonable to me.
****************************************
Jean-Marie THOMAS
mailto:jmthomas at agat.net
Conseil et Audit en Ingenierie de Calcul
Strasbourg, France
http://www.agat.net
****************************************
-----Original Message-----
From: W.W. Sampson [mailto:w.sampson at umist.ac.uk]
To: mathgroup at smc.vnet.net
Subject: [mg17242] [mg17202] Counting list elements above/below a given value
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