MathGroup Archive 2007

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

Search the Archive

Re: style question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79496] Re: style question
  • From: Donald DuBois <donabc at comcast.net>
  • Date: Sat, 28 Jul 2007 05:24:46 -0400 (EDT)

>Correction to self. I overlooked the three->dimensionality of m1 and
>m2. Again I'm without Mathematica; still you might try:
>
>matches = MapThread[Equal, {m1, m2}, 3];
>Count[matches, True, {3}]
>
>By the way, your syntax for the first argument of >RandomInteger
>appears to be undocumented.
>
>Vince Virgilio
>



Hello Vince:

I think you were right the first time.

{m1, m2} = RandomInteger[1, {2, 10^5, 2, 2}];

(* First time *)

matches1 = MapThread[Equal, {m1, m2}];
Count[matches1, True]

Out[30]= 6189

(* Second time *)

matches2 = MapThread[Equal, {m1, m2}, 3];
Count[matches2, True, {3}]

Out[31]= 200218

>From probability, one would expect about
6250 matches.  This is because {{a,b},{c,d}} 
can have 16 different
values since a, b , c and d are either 0 or 1 with 
equal probability.  So, {{a,b},{c,d}} will match 
{{e,f},{g,h}} approx. 1/16-th of the time.
1/16-th of 10^5 = 6250.

Best,
Don


  • Prev by Date: Re: Mathematica to .NET compiler
  • Next by Date: Re: Workbench - any use to me?
  • Previous by thread: Re: Re: style question
  • Next by thread: Re: style question