3
$\begingroup$

I have 120 blocks. Each block is one of two different materials, 3 different colors, 4 different sizes and 5 different shapes. No two blocks are exactly the same of all four properties. I take two blocks at random. What is the probability the two blocks have exactly two of the four properties the same?

I try with R to replicate this:

library(matrixStats)
replicateExperiment<-function(i,stateSpace) length(which(colDiffs(stateSpace[sample(1:120,2),])==0))==2
stateSpace<-data.matrix(expand.grid(M=1:2,C=1:3,Si=1:4,Sh=1:5))
mean(c(lapply(1:100000,replicateExperiment,stateSpace=stateSpace),recursive=TRUE))

I get something more like $P(\text{2 out of 4 characteristics are the same)}\approx .3$.

My question is, how can we compute the number of blocks that have exactly 2 characteristics in common out of all 120 boxes.

What I have done so far:

Let's start with having three in common out of 4 characteristics (4 out of 4 is not possible). There are 4 possible ways to share 3 out of 4 characteristics.

I will denote the characteristics as $\{M,C,Si,Sh\}$ so $P(B_2=\{1,1,1,0\}|B_1=\{1,1,1,0\})$ is the probability that box 2 shares its first three characteristics with box 1 given that box one has characteristics $\{1,1,1,*.*\}$.

Then we have

$$P(B_2 \text{ has 3 elements in common with } B_1)=P(B_2=\{1,1,1,0\}|B_1=\{1,1,1,0\})*P(B_1=\{1,1,1,0\})+P(B_2=\{1,1,0,1\}|B_1=\{1,1,0,1\})*P(B_1=\{1,1,0,1\})+P(B_2=\{1,0,1,1\}|B_1=\{1,0,1,1\})*P(B_1=\{1,0,1,1\})+P(B_2=\{0,1,1,1\}|B_1=\{0,1,1,1\})*P(B_1=\{0,1,1,1\})$$

$$P(B_2 \text{ has 3 elements in common with } B_1)=(4*5*24+3*4*30+2*3*40+1*2*60)\frac{1}{120*119}\approx0.084$$ which is close enough to the value from the simulation code (modified to count the number of 3-ties).

The problem:

Now, I use the same reasoning to compute:

$$P(B_2 \text{ has 2 or more elements in common with } B_1)=(19*20*6+11*12*10+9*10*12+14*15*8+7*8*15+5*6*20)\frac{1}{120*119}\approx0.54$$

This is not close at all to the value from the simulation code (modified to count all $2^+$ ties).

$\endgroup$
4
$\begingroup$

Here's an ultra kludgy explanation: you need to generate vectors of the form (x4, x3, x2, x1) (where xi = characteristic) and each is drawn from its own domain.

Consider that you want exactly 2 characteristics to match, so given one box, the other one should have 2 characteristics that match (so theres only one way to set those values) and 2 characteristics that don't. (so xi's domain's size minus one ways). And, happily, these are all mutually exclusive.

Vary the characteristics in pairs (and forsaking all elegance): (2-1)((3-1)+(4-1)+(5-1)) + (2)((3)+(4)) + (12) = 35 (second boxes for each first box);

35/119 is about .29

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ This is so elegant, I need to take a breath! $\endgroup$ – user603 Feb 2 '16 at 19:57
1
$\begingroup$

Suppose I draw two boxes with the same color, size, and shape (but different material). That pair of boxes is counted in the term for the same {color, size}, but also in the term for the same {color, shape}, and in the term for the same {size, shape}....

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Ok, I understand the problem, but how to compute the total number of doubly counted boxes? Or what formula to use to avoid double counting them in the first place? $\endgroup$ – user603 Feb 1 '16 at 22:16
  • $\begingroup$ Same basic way that you count the singly counted boxes, just subtract them instead of adding. :) $\endgroup$ – djs Feb 1 '16 at 22:18
0
$\begingroup$

I have answered it here:

This is my answer.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.