0% found this document useful (0 votes)
14 views

Lecture 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lecture 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

MM 225: AI and Data Science

Permutations, combinations and binomial

M P Gururajan and Hina A Gokhale

August 22, 2023

Guru and Hina AI and Data Science August 22, 2023 1 / 35


Lecture 5: Permutations, combinations and binomial

Guru and Hina AI and Data Science August 22, 2023 2 / 35


Outline

1 Recall

2 Birthday problem

3 Binomial coefficients

4 The icon problem

Guru and Hina AI and Data Science August 22, 2023 3 / 35


Recall

The problem of points

Suppose G and H are playing several games. G needs three more wins and H needs two more
wins to get the stakes. If the games are stopped at this point, what is the fair division of
stakes? Assume that the stakes are Rs. 64.

Guru and Hina AI and Data Science August 22, 2023 4 / 35


Recall

Pascal’s and Fermat’s solutions

Pascal: Algorithmic
Involved Pascal’s identity
Fermat: combinatoric
This lecture: binomial (Pascal’s identity) and permutations and combinations

Guru and Hina AI and Data Science August 22, 2023 5 / 35


Birthday problem

Birthday problem

Guru and Hina AI and Data Science August 22, 2023 6 / 35


Birthday problem

Questions

Question
In a class of 200 students, what is the probability that two students share the same birthday?

Question
How big should a class be so that the probability of two students sharing the same birthday is
more than 50%?

Guru and Hina AI and Data Science August 22, 2023 7 / 35


Birthday problem

Guess

Question
In a class of 200 students, what is the probability that two students share the same birthday?

Can we guess that this will be about 200/365 ≈ 0.548

Guru and Hina AI and Data Science August 22, 2023 8 / 35


Birthday problem

Answer
200
Probablity is ≈ 365 = 0.55

Link:
https://www.menti.com/alyv6higa18m

Code: Go to menti.com and use code


5529 0593

Guru and Hina AI and Data Science August 22, 2023 9 / 35


Birthday problem

Results

Results of the poll

Guru and Hina AI and Data Science August 22, 2023 10 / 35


Birthday problem

Sample space

A sequence of 200 birthdays – assuming no repetition


In other words, we find the probability that no two people have the same birthday
We get the probability that at least two share a birthday by subtracting this number from
unity!

Guru and Hina AI and Data Science August 22, 2023 11 / 35


Birthday problem

Number of sequences

Assume nobody is born in a leap year


There are 365 possible birthdays
First person could be born on any of the 365 days
Second person has only 364 possibilities
Third person has only 363 possibilities
... and so on
200th person has 365 − 200 + 1 = 166 possibilities
What are all the number of sequences?

Guru and Hina AI and Data Science August 22, 2023 12 / 35


Birthday problem

Permutation

Definition
Let A be any finite set. A permutation of A is a one-to-one mapping of A into itself.

Theorem
The total number of permutations of a set A of n elements is n!.

Definition
Let A be an n-element set and let k be an integer between 0 and n. Then a k-permutation of
A is an ordered listing of a subset of A of size k.

Theorem
n!
The total number of k-permutations of a set A of n elements is (n−k)!

Guru and Hina AI and Data Science August 22, 2023 13 / 35


Birthday problem

Calculation

Assume nobody is born in a leap year


There are 365 possible birthdays
What is the probability that all the birth days are distinct?
First person could be born on any of the 365 days
Second person has 364 possibilities
Third person has 363 possibilities ...
200th person has 365 − 200 + 1 = 166 possibilities

Guru and Hina AI and Data Science August 22, 2023 14 / 35


Birthday problem

Probability

365·364·363···166
Thus, for 200 students, the probability is 365200
The probability that two students have the same birthday is closer to 1
Note: factorial and calculation of the same using Stirling’s approximation

Guru and Hina AI and Data Science August 22, 2023 15 / 35


Birthday problem

Guess

Question
How big should a class be so that the probability of two students sharing the same birthday is
more than 50%?
Can we guess this number and verify the guess using a python script?

Guru and Hina AI and Data Science August 22, 2023 16 / 35


Binomial coefficients

Binomial coefficients

Guru and Hina AI and Data Science August 22, 2023 17 / 35


Binomial coefficients

Combinations

Consider a set U with n elements


Let ϕ the null set, and the set U be also considered as subsets of U
What are the number of distinct subsets of U: 2n
What are the number of distinct subsets of U that has j elements?
Answered by combinations!

Guru and Hina AI and Data Science August 22, 2023 18 / 35


Binomial coefficients

Binomial coefficients

n

Number of distinct subsets with j elements that can be chosen with n elements: j (n
choose j)
n

j : binomial coefficient
Assume n > 0
There is only one way to choose zero elements or n elements
For integers j and n, with 0 < j < n
Theorem
n n−1 n−1
  
j = j + j−1

Guru and Hina AI and Data Science August 22, 2023 19 / 35


Binomial coefficients

Bernoulli trials

Definition
A Bernoulli trials process is a sequence of n chance experiments such that each experiment has
two possible outcomes with probabilities of p for ‘success’ and 1 − p for ’failure’

What is the probability that in n Bernoulli trials there are exactly j successes?
Probability b(n, p, j) = nj p j q n−j


Guru and Hina AI and Data Science August 22, 2023 20 / 35


Binomial coefficients

Binomial distribution

Definition
Let n be a positive integer and 0 < p < 1. The random variable B which counts the number
of successes in a Bernoulli trials process with parameters n and p is distributed as binomial
distribution b(n, p, k)

Use of binomial distribution: Tutorials. For example, to check the number of trials needed to
determine the efficacy of a new medicine and simulation of Galton board

Guru and Hina AI and Data Science August 22, 2023 21 / 35


Binomial coefficients

A problem

G and H have given a quiz to 300 students in their data analysis course. The quiz consisted of
10 true or false questions. If the students tossed a coin to answer the questions, how many
students would have scored ten on ten? How many zero on ten? If there are about 100
students who had scored 10 on 10 and about 5 scored 0 on 10, what can you conclude about
the difficulty level of the quiz?

Guru and Hina AI and Data Science August 22, 2023 22 / 35


Binomial coefficients

Python to answer the question

n
p j q n−j

Probability b(n, p, j) = j
n = 10; p = 0.5; j = 0 and j = 10
from scipy.stats import binom
binom.pmf(0,10,0.5)
binom.pmf(10,10,0.5)
Probability: ≈ 0.001

Guru and Hina AI and Data Science August 22, 2023 23 / 35


Binomial coefficients

Python script

from scipy.stats import binom


import matplotlib.pyplot as plt

x = binom.rvs(10,0.5,size=300)

plt.hist(x,bins=[0,1,2,3,4,5,6,7,8,9,10])
plt.show()

Guru and Hina AI and Data Science August 22, 2023 24 / 35


The icon problem

The icon problem

Guru and Hina AI and Data Science August 22, 2023 25 / 35


The icon problem

Question

I very carefully arrange the app icons on my cell phone:


Moive apps: Netflix, Google tv, Mubi, Prime Video, Disney-Hotstar, Zee 5
Entertainment apps: Alexa, fire tv, amazon music, youtube, apple music, eppo music,
pocket casts
Call taxi /auto aggregators: Uber, Ola, Namma Yatri
Food: Zwiggy, Zomato
Frequent: camera, messages, whatsapp, gmail, maps, calendar, authenticator
My niece takes my phone and randomly arranges the icons. What is the probability that none
of the icons end up at their original position? At least k of them end up in their original
position?

Guru and Hina AI and Data Science August 22, 2023 26 / 35


The icon problem

Fixed points

Permutations: one-to-one mapping of a set onto itself


The points that map to themselves after random permutations: fixed points
Library problem, hat check problem, ...
How to solve these problems?
Simulation! Certainly.
Exact solution?

Guru and Hina AI and Data Science August 22, 2023 27 / 35


The icon problem

Inclusion-Exclusion principle

Theorem
Let P be a probability measure on a sample space Ω and let (A1 , A2 , ...An ) be a finite set of
elements. Then,
n
X
P(A1 ∪ A2 ∪ · · · ∪ An ) = P(Ai ) (1)
i=1
X
− P(Ai ∩ Aj )
1≤i<j≤n
X
+ P(Ai ∩ Aj ∩ Ak )
1≤i<j<k≤n
−···

Guru and Hina AI and Data Science August 22, 2023 28 / 35


The icon problem

Inclusion-Exclusion principle

A generalisation of P(A ∪ B) = P(A) + P(B) − P(A ∩ B)


To find the probability that at least one event out of n events Ai occurs, add the
probability of each event, subtract the probabilities of all possible two-way interactions,
add the probability of all three-way interactions and so on.

Guru and Hina AI and Data Science August 22, 2023 29 / 35


The icon problem

Icon problem: solution using inclusion-exclusion principle


A: ordered set of n icons
Ai : the event that the i-th element remains fixed under permutation – a one-to-one map
of A onto itself
If ai is fixed, the remaining (n − 1) elements are arbitrarily mapped
There are (n − 1)! such permutations
P(Ai ) = (n−1)!
n! = n1
There are n choices for ai
The first term in Eq. (1) is 1
n
X
P(A1 ∪ A2 ∪ · · · ∪ An ) = P(Ai )
i=1
X
− P(Ai ∩ Aj )
1≤i<j≤n
X
+ P(Ai ∩ Aj ∩ Ak )
1≤i<j<k≤n
−···
Guru and Hina AI and Data Science August 22, 2023 30 / 35
The icon problem

Other terms
Let (ai , aj ) be fixed
The permutations of remaining elements is (n − 1)!
Thus P(Ai ∩ Aj ) = (n−2)!
n!
1
= n(n−1)
There are n2 such terms


The second term in Eq. (1) is thus n2 n(n−1) = n(n−1)


 1 1 1
2! n(n−1) = 2!
1
Similarly, the third term is 3!
n
X
P(A1 ∪ A2 ∪ · · · ∪ An ) = P(Ai )
i=1
X
− P(Ai ∩ Aj )
1≤i<j≤n
X
+ P(Ai ∩ Aj ∩ Ak )
1≤i<j<k≤n
−···

Guru and Hina AI and Data Science August 22, 2023 31 / 35


The icon problem

Solution

P(at least one fixed point)

1 1 1
1− + − · · · (−1)n−1 (2)
2! 3! n!
P(no fixed point)
1 1 1
− + · · · (−1)n (3)
2! 3! n!
1
P(no fixed point) is the sum of the first n terms of the expansion for e

Guru and Hina AI and Data Science August 22, 2023 32 / 35


The icon problem

‘No fixed point’ as a function of n

Figure: The dotted line corresponds to e1 .

Guru and Hina AI and Data Science August 22, 2023 33 / 35


The icon problem

Summary

Permutations
Combinations
Bernoulli trials and binomial distribution
Next lecture: Conditional probability

Guru and Hina AI and Data Science August 22, 2023 34 / 35


The icon problem

THANK YOU!!!

Guru and Hina AI and Data Science August 22, 2023 35 / 35

You might also like