# How can I count the number of times the $i$th element of two lists are equal?

I'm trying to sample $$100$$ numbers from the Geometric$$(0.3)$$ distribution, and $$100$$ numbers from the Geometric$$(0.6)$$ distribution, and compute $$\frac{\text{number of times Geom(0.3) value = Geom(0.6) value}}{100}$$ My approach is to do

{RandomVariate[GeometricDistribution[0.3], 100], RandomVariate[GeometricDistribution[0.5], 100]}


which creates a list of two lists, one containing the samples from Geom(0.3) and the other containing the samples from Geom(0.6). Now I just need to count how many times the $$i$$th element of the two lists are equal. How can I do that? Or is there a better way to do this whole sampling thing?

dist1=RandomVariate[GeometricDistribution[0.3], 100];
dist2= RandomVariate[GeometricDistribution[0.6], 100];

Count[dist1-dist2,0]

Total@UnitBox[dist1-dist2]

SeedRandom[0];

a = RandomVariate[GeometricDistribution[0.3], 10];
b = RandomVariate[GeometricDistribution[0.6], 10];

c = Transpose[{a, b}]


{{1, 2}, {1, 0}, {1, 0}, {1, 0}, {0, 1}, {0, 0}, {4, 0}, {1, 4}, {6, 0}, {1, 1}}

Count[{x_, x_}] @ c


2

SequenceCount[c, {x_} /; Equal @@ x]


2

a = RandomVariate[GeometricDistribution[0.3], 10];
b = RandomVariate[GeometricDistribution[0.6], 10];

c = Transpose[{a, b}]


{{1, 2}, {1, 0}, {1, 0}, {1, 0}, {0, 1}, {0, 0}, {4, 0}, {1, 4}, {6, 0}, {1, 1}}

Grabbing the @eldo's data and using Cases:

Length@Cases[c, {x_ ..}]


2

Grabbing @eldo's data:

SeedRandom[0];

a = RandomVariate[GeometricDistribution[0.3], 10];
b = RandomVariate[GeometricDistribution[0.6], 10];

c = Transpose[{a, b}]

(* {{1, 2}, {1, 0}, {1, 0}, {1, 0}, {0, 1}, {0, 0}, {4, 0}, {1, 4}, {6, 0}, {1, 1}} *)

Total[MapApply[KroneckerDelta]@c]

(* 2 *)


Or:

MapThread[KroneckerDelta, {a, b}] // Total

(* 2 *)

m = RandomInteger[GeometricDistribution[0.3], {100, 2}];
Count[ Equal @@@ m, True]

SeedRandom[0];
a = RandomVariate[GeometricDistribution[0.3], 10];
b = RandomVariate[GeometricDistribution[0.6], 10]; (* Thanks @eldo )


Subtract @@ {a, b} // Unitize // Count[0]
Count[True]@MapThread[#1 === #2 &, {a, b}]
Count[True][Equal @@@ Transpose[{a, b}]]
ArrayReduce[Apply@SameQ, {a, b}, 1]


2