A Probability Birthday problem along with Julia Programming

Probability theory is nothing but common sense reduced to calculation.

Pierre-Simon Laplace

Today we will be discussing a problem from the second chapter of A First Course in Probability(Eighth Edition) by Sheldon Ross.

Let's see what the problem says:

Describing the Problem

The problem(prob-48) says:

Given 20 people, what is the probability that among the 12 months in the year, there are 4 months containing exactly 2 birthdays and 4 containing exactly 3 birthdays?

So, what do we mean by this? Let's suppose we have $20$ people, named $p_1,p_2,\cdots , p_{20}$ and we will be representing the months by numbers like, January$\to 1$, February $\to 2$ , March $\to 3$ ,$\cdots $,December $\to 12$.

Then, One possible combination of birthday can be,

People Name Birthday Month
$p_1$$01$
$p_2$$05$
$p_3$$09$
$p_4$$04$
$p_5$$07$
$p_6$$12$
$p_7$$03$
$p_8$$09$
$p_9$$06$
$p_{10}$$11$
$p_{11}$$12$
$p_{12}$$01$
$p_{13}$ $07$
$p_{14}$ $02$
$p_{15}$ $09$
$p_{16}$ $12$
$p_{17}$ $02$
$p_{18}$ $11$
$p_{19}$ $06$
$p_{20}$ $08$

In this case, January ($01$) has $2$ birthdays, February($02$) has $2$ birthdays. Similarly we can find the number of birthday in each month. But in our question it is said that one possible arrangement exist where any four months (suppose January, February, March and April) each holds $2$ birthday (in total in this group there are $4\times 2 = 8$ birthday) and another four months (suppose June, July, September and December) each holds $3$ birthday (in total this group has $4\times 3 = 12$ birthdays). We have to find the probability of existence of such groups.

I hope the problem is clear. Let's see how to solve this.

Solution - 1

To solve this problem one must notice the most important point. This problem treats each people in same footing, means they are indistinguishable. Normally, we humans are distinguishable as you can see people's face or maybe use their name to make difference.

So, The number of all possible combinations (outcome) = $12^{20}$.

Now, for our particular case, we must group $4$ months from $12$ months where each contains $2$ birthdays. This can be done in ${12 \choose 4}$ ways. After this again we have to choose $4$ months from remaining $8$, where each contains $3$ birthdays. This can be done in ${8 \choose 4}$ ways.

So, we can choose months (or the month combination is ) in ${12 \choose 4}{8 \choose 4}$ ways. Using multinomial theorem, we can write this number equals to ${12 \choose 4 4 4}$ (we will not use this).

Now, we have $20$ people and we have to to assign months with them.

Remember we have to take $3$ people and give them one single month. This can be done in ${20 \choose 3}$ ways. Again we have to take $3$ people and group them. This time the possible ways are ${17 \choose 3}$. Again doing the same gives us ${14 \choose 3}$ ways (this is done 4 times as we have $4$ such months which contains $3$ birthdays). So, for this group the number of possible combinations is ${20 \choose 3} {17 \choose 3} {14 \choose 3} {11 \choose 3} $.

Now, we still have $4$ months where each of those contains 2 birthdays. This gives a total of $ {8 \choose 2} {6 \choose 2} {4 \choose 2} {2 \choose 2} $ ways.

So, the total numbers of ways of assigning $20$ people to those months is $$ {20 \choose 3} {17 \choose 3} {14 \choose 3 } {11 \choose 3} {8 \choose 2} {6 \choose 2} {4 \choose 2} {2 \choose 2} = \frac{20!}{3!\cdot 17!} \frac{17!}{3!\cdot 14!} \frac{14!}{3!\cdot 11!} \frac{11!}{3!\cdot 8!} \frac{8!}{2!\cdot 6!} \frac{6!}{2!\cdot 4!} \frac{4!}{2!\cdot 2!} \frac{2!}{2!\cdot 0!} = \frac{20!}{12^4} $$

So, The probability = ${{12\choose 4}{8\choose 4}\frac{20!}{12^4}\over 12^{20}} = 0.00106042009902$

Easy right? This can also be solved using a analogy of dice with $12$ sides.

Solution-2

In this method we consider a dice with $12$ sides. Each person's birthday is within 12 months and each of them are independent. So, If that dice is rolled 20 times, then what is the probability to get same number $3$ times for $4$ different number and same number $2$ times for other $4$ different number, i.e., what is the probability to get a state like $11223344666777888999$?

This can be solved in $4$ simple steps.

  1. Among $12$ faces, $8$ of them can be taken in $a={12 \choose 8} = 495$ ways.
  2. Among those $8$ faces, $4$ are groups of $2$'s and $4$ are groups of $3$'s. The number of ways = $b = {8 \choose 4}{4 \choose 4} = 70$.
  3. If we roll it $20$ times or take $20$ dices, then there are $4$ sets of $3$ and $4$ sets of $2$. In this case, the possibilities $c = \frac{20!}{(3!)^4 (2!)^4}$.
  4. The sample space's element number $d = 12^{20}$

Hence, probability $=\frac{a\times b \times c}{d} = 0.0010604200990$

Whenever I solve this type of problems, It always feel like may be !! maybe!! I have made some mistake. To be sure that we are correct, we should perform experiment with a dice or may be take many groups of $20$ people and calculate probability. But It is practically impossible!!

Not quite... We can always use programming language to do the experiments and verify.

Verifying using Julia

First we have to know few tricks.

arr = [2,6,2,10]
#Creates an array

Now, how can we know if there are two 2's inside of this array?, an easy solution will be

arr.==2
#Check if any element equal to 2
#This gives an output as:
#BitVector: [true,false,true,false]

And then we use sum

sum(arr.==2)
#return number of times 2 is there
#output: 2

Using this we write a simple code:

begin
    function prob(n::Int)
	favour = 0
	for ex_num=1:n
		months = rand(1:12,20)
		nums = [sum(months.==i) for i=1:12]
		if sum(nums.==3)==4 && sum(nums.==2)==4
			favour += 1
		end
	end
	probability = favour/n
    end
end

This function beautifully give you the value. We need more sample, so I have used $n=1,00,00,000$.

This gives the result:3

prob_10_000_000 = prob(10_000_000)
#output: 0.0010616

Beautiful isn't it?, just using few lines of code we have verified our answer.

I encourage you to play with the code.

This is all for today. I hope you have learnt something new.

Intertwined Conditional Probability | ISI MStat 2016 PSB Problem 4

This is an interesting problem from intertwined conditional probability and Bernoulli random variable mixture, which gives a sweet and sour taste to Problem 4 of ISI MStat 2016 PSB.

Problem

Let \(X, Y,\) and \(Z\) be three Bernoulli \(\left(\frac{1}{2}\right)\) random variables such that \(X\) and \(Y\) are independent, \(Y\) and \(Z\) are independent, and \(Z\) and \(X\) are independent.
(a) Show that \(\mathrm{P}(X Y Z=0) \geq \frac{3}{4}\).
(b) Show that if equality holds in (a), then $$
Z=
\begin{cases}
1 & \text { if } X=Y, \\
0 & \text { if } X \neq Y\\
\end{cases}
$$

Prerequisites

Solution

(a)

\( P(XYZ = 0) \iff P( { X = 0} \cup {Y = 0} \cup {Z = 0}) \)

$$= P(X = 0) + P(Y = 0) + P(Z= 0) - P({ X = 0} \cap {Y = 0}) - P({Y = 0} \cap {Z= 0}) - P({X = 0} \cap {Z= 0}) + P({X = 0} \cap {Y = 0} \cap {Z= 0}). $$

We use the fact that \(X\) and \(Y\) are independent, \(Y\) and \(Z\) are independent, and \(Z\) and \(X\) are independent.

$$= P(X = 0) + P(Y = 0) + P(Z= 0) - P({ X = 0})P({Y = 0}) - P({Y = 0})P({Z= 0}) - P({X = 0})P({Z= 0}) + P({X = 0},{Y = 0},{Z= 0})$$.

\(X, Y,\) and \(Z\) be three Bernoulli \(\left(\frac{1}{2}\right)\) random variables. Hence,

\( P(XYZ = 0) = \frac{3}{4} + P({X = 0},{Y = 0},{Z= 0}) \geq \frac{3}{4}\).

(b)

\( P(XYZ = 0) = \frac{3}{4} \iff P({X = 0},{Y = 0},{Z= 0}) = 0 \).

Now, this is just a logical game with conditional probability.

\( P({X = 0} |{Y = 0},{Z= 0}) = 0 \Rightarrow P({Z= 0} |{Y = 0},{X = 1}) = 1\).

\( P({Y = 0} |{X = 0},{Z= 0}) = 0 \Rightarrow P({Z= 0} |{X = 0},{Y = 1}) = 1\).

\( P({Z = 0} |{X = 0},{Y= 0}) = 0 \Rightarrow P({Z = 1} |{X = 0},{Y= 0}) = 1\).

\( P( Z = 0) = P({X = 1},{Y = 0},{Z= 0}) + P({X = 0},{Y = 1},{Z= 0}) + P({X = 1},{Y = 1},{Z= 0}) + P({X = 0},{Y = 0},{Z= 0})\)

\( = \frac{1}{4} + \frac{1}{4} + P({X = 1},{Y = 1},{Z= 0}) \).

Now, \(Z\) is a Bernoulli \(\left(\frac{1}{2}\right)\) random variable. So, \(P(Z = 0) =\frac{1}{2}\) \( \Rightarrow P({X = 1},{Y = 1},{Z= 0}) = 0 \Rightarrow P({Z = 0} | {Y = 1},{X= 1}) = 0 \).

\( P({Z= 0} |{Y = 0},{X = 1}) = 1\).

\(P({Z= 0} |{X = 0},{Y = 1}) = 1\).

\(P({Z = 1} |{X = 0},{Y= 0}) = 1\).

\( P({Z = 1} | {Y = 1},{X= 1}) = 1\).

Hence, $$
Z=
\begin{cases}
1 & \text { if } X=Y, \\
0 & \text { if } X \neq Y\\
\end{cases}
$$.

Venny Venny AMy GMy | ISI MStat 2016 PSB Problem 3

This problem is a very basic and cute application of set theory, Venn diagram and AM GM inequality to solve the ISI MStat 2016 PSB Problem 3.

Problem - Venn diagram and AM GM inequality

For any two events \(A\) and \(B\), show that
$$
(\mathrm{P}(A \cap B))^{2}+\left(\mathrm{P}\left(A \cap B^{c}\right)\right)^{2}+\left(\mathrm{P}\left(A^{c} \cap B\right)\right)^{2}+\left(\mathrm{P}\left(A^{c} \cap B^{c}\right)\right)^{2} \geq \frac{1}{4}
$$

Prerequisites

Solution

Draw the Venn Diagram

venn diagram and am gm inequality problem

P(region Red) = \(Y\)

P(region Blue) = \(Z\)

P(region Grey) = \(W\)

P(region Brown) = \(X\)

Observe that \( W + X + Y + Z = 1\). \( W, X, Y, Z \geq 0\).

Now, Calculate Given Probability of Sets in terms of \( W, X, Y, Z \).

\({P}(A \cap B) = Z\).

\({P}\left(A \cap B^{c}\right) = Y\).

\({P}\left(A^{c} \cap B\right) = W\).

\( {P}\left(A^{c} \cap B^{c}\right) = X\).

The Final Inequality

\( W, X, Y, Z \geq 0\).

\( W + X + Y + Z = 1\).

Observe that \( 3(W^2 + X^2 + Y^2 + Z^2) = (W^2+X^2) + (W^2+Y^2) + (W^2+Z^2) + (X^2+Y^2) + (X^2+Z^2) + (Y^2+Z^2)\).

\( 3(W^2 + X^2 + Y^2 + Z^2) \geq 2WX + 2WY + 2WZ + 2XY + 2XZ + 2YZ \) by AM - GM Inequality.

\( \Rightarrow 4(W^2 + X^2 + Y^2 + Z^2) \geq (W + X + Y + Z)^2 = 1\).

\( \Rightarrow (W^2 + X^2 + Y^2 + Z^2) \geq \frac{1}{4} \).

Hence,

$$
(\mathrm{P}(A \cap B))^{2}+\left(\mathrm{P}\left(A \cap B^{c}\right)\right)^{2}+\left(\mathrm{P}\left(A^{c} \cap B\right)\right)^{2}+\left(\mathrm{P}\left(A^{c} \cap B^{c}\right)\right)^{2} \geq \frac{1}{4}
$$

Permutation - AMC 10B - 2020 - Problem No.5

What is Permutation ?


Permutation is the act of arranging the members of a set into a sequence or order, or, if the set is already ordered, rearranging (reordering) its elements—a process called permuting.

Try the problem from AMC 10B - 2020 - Problem 5


How many distinguishable arrangements are there of  1 brown tile,1 purple tile ,2 green tiles and 3 yellow tiles in a row from left to right ? (Tiles of the same color are indistinguishable.)

A) 210 B) 420 C) 630 D) 840 E) 1050

American Mathematics Competition 10 (AMC 10B), 2020, Problem Number - 5

Permutation

5 out of 10

Mathematical Circle

Knowledge Graph


Permutation- knowledge graph

Use some hints


If you really need a hint you can go through the concept of probability at first : In its simplest form, probability can be expressed mathematically as: the number of occurrences of a targeted event divided by the number of occurrences plus the number of failures of occurrences (this adds up to the total of possible outcomes):

\(p(a) = \frac {p(a)} { [P(a) + p(b)] } \)

Let's try to find how many possibilities there would be if they were all distinguishable, then divide out the ones we over counted . There are  7! ways to order 7 objects. However, since there's 3!= 6 ways to switch the yellow tiles around without changing anything (since they're indistinguishable) and  2! = 2 ways for green tiles.

I am sure that you are almost there for the final calculation but let me help those who are still not there

\(\frac {7!}{6 \cdot 2} = 420 \) .

So the correct answer is B) 420

Subscribe to Cheenta at Youtube