Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Logical comparisons of items in a two lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75463] Re: [mg75446] Logical comparisons of items in a two lists
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 2 May 2007 03:45:56 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

a=Table[Random[],{10}];

b=Table[Random[],{10}];

Count[Thread[a>b],True]

8

Total[Boole[Thread[a>b]]]

8

Length[Pick[a, Thread[a>b]]]

8


Bob Hanlon

---- "actuary at mchsi.com" <actuary at mchsi.com> wrote: 
> Hello:
> 
> I have two lists of real numbers, a & b.  I want two compare
> individual items in one list to the corresponding items in the other
> list.  For example Is a[[1]] > b[[1]]. At the end of the comparisons,
> I want to count the "Trues".  I know how to do this use a "Table"
> statement and a "Count" statement.  Is there a quicker, more efficient
> way of counting the number of "Trues".
> 
> Thanks
> 
> Larry
> 
> 



  • Prev by Date: Integrate
  • Next by Date: Thanks to responders
  • Previous by thread: Re: Logical comparisons of items in a two lists
  • Next by thread: Re: Logical comparisons of items in a two lists