Re: Count using pattern on two different matrices

*To*: mathgroup at smc.vnet.net*Subject*: [mg57082] Re: [mg57079] Count using pattern on two different matrices*From*: Bob Hanlon <hanlonr at cox.net>*Date*: Sun, 15 May 2005 03:03:35 -0400 (EDT)*Reply-to*: hanlonr at cox.net*Sender*: owner-wri-mathgroup at wolfram.com

L1=Table[Random[Integer]==1,{5},{2}] {{True, False}, {True, True}, {True, False}, {True, True}, {True, False}} L2=Table[Random[Integer]==1,{5},{3}] {{False, True, True}, {True, True, True}, {False, True, True}, {False, True, True}, {False, True, False}} Count[Thread[{L1[[All,2]],L2[[All,3]]}], _?(#[[1]]==False&&#[[2]]==True&)] 2 Count[Thread[{L1[[All,2]],L2[[All,3]]}], _?(Not[#[[1]]]&&#[[2]]&)] 2 Bob Hanlon > > From: Lee Newman <leenewm at umich.edu> To: mathgroup at smc.vnet.net > Date: 2005/05/14 Sat AM 04:58:25 EDT > Subject: [mg57082] [mg57079] Count using pattern on two different matrices > > I have two matrices with an equal number of rows, but not necessarily > columns, for example: > > L1= {{True,False},{False, True},{False, False}, etc.....} ; > L2= {{True,False,False},{True, True,True},{False, True,False}, etc.....} ; > > I would like to compute a count of the number of rows in which one of > the columns of L1 meets some criterion, and one of the columns of L2 > meets some criterion, i.e. If L1[[row,2 ]]==False and > L2[[row,3]]==True then this row contributes 1 to the count. > > I suspect that there is an elegant way to do this, perhaps using Count[] > and MapThread, but I can't figure it out other than resorting to a > rather clumsy For or Do loop that would check line by line and maintain > a counter. > > Any help would be appreciated, > Lee > >