Probability, Sets, Distribution and Random Variable - WIP
Probability, Sets, Distribution and Random Variable - WIP
AccioJob/ DataScience-Fundamentals
Content
● Probability
● Sets and Venn Diagrams
● Bayes Theorem and Conditional Probability
● Mutually Exclusive Events and Independent Events
● Random variables
● Probability Distributions - Bernoulli, Poisson, Binomial, Normal
● Permutations and Combinations
Probability
Probability Fundamentals
What is the Probability of an Event?
Probability is a measure of ‘uncertainty’ or ‘likelihood’ or ‘chance’ that a particular event or outcome will
occur. It represents the ratio of the ‘favorable outcomes’ to the ‘total possible outcomes’ in a given
situation.
With the concept of probability, we can quantify uncertainty and randomness that we experience in our
daily lives. With any random phenomenon, the probability of a particular outcome is the proportion of
times that the outcome would occur in a long run of observations.
P(H) P(T)
Count of 1 1
outcomes
1/2 1/2
Probability Tree of Coin experiment - Multiple flips
The probability tree illustrates the possible outcomes of a sequence of 5 coin tosses. For the sake of brevity only the 16
sequences starting with heads and their characteristics-relative frequency of heads and tails, longest run within the sequence,
number of runs within the sequence, and alternation rate-are displayed.
Probability -for
Themore
Dicecoins
Experiment
What happens when we roll 2 dice? How does probability work for different
outcomes? What is the probability of rolling a 4 or a 7?
Total Outcomes (The Sample Space)
[1][1], [1][2], [1][3], [1][4], [1][5], [1][6],
[2][1], [2][2], [2][3], [2][4], [2][5], [2][6],
[3][1], [3][2], [3][3], [3][4], [3][5], [3][6], n(Total)
[4][1], [4][2], [4][3], [4][4], [4][5], [4][6],
[5][1], [5][2], [5][3], [5][4], [5][5], [5][6], 36
[6][1], [6][2], [6][3], [6][4], [6][5], [6][6].
n(4 or 7)
3 36
4 36
5 36
6 36
7 36
8 36
9 36
10 36
12 36
P(Ace) = 4/52
A compound event is more complex Example - Find the probability of Flipping Heads and Rolling
than a simple event, as it involves the number Greater Than 4.
probability of more than one
outcome. It is as a combination of Possible outcomes of coin {H,T}
two or more simple events. Possible outcomes of dice {1,2,3,4,5,6}
A∪B Union Elements that belong to set A or set B A ∪ B = {1, 7, 9, 13, 15, 21, 23}
A∩B Intersection Elements that belong to both the sets, A and B A ∩ B = {9, 13, 23 }
A⊆B Subset subset has few or all elements equal to the set {7, 15} ⊆ {7, 13, 15, 21}
{7, 15} ⊆ {7, 15}
A⊄B Not subset left set is not a subset of right set {1, 20} ⊄ B
A⊇B Superset Set A has more elements or equal to the set B {1, 7, 9, 13, 15, 23} ⊇ {7, 13, 15, 23}
Equality Both sets have the same members. Order need not be {7, 13,15} = {13, 7, 15}
A=B
same.
Ā or A’ or Ac Complement All the objects that do not belong to set A If U = {1, 2, 7, 9, 13, 15, 21, 23,
28, 30}; A = {1, 7, 9, 13, 15, 23}
Ac = {2, 21, 28, 30}
Types of Sets
Set Type Definition Example
A set that has only one element is called a singleton Set A = { k | k is an integer
Singleton Sets set or also called a unit set. between 7 and 9} which is A =
{8}.
Two Sets are said to be disjoint when they do not A = {1,2,3,4} B = {5,6,7,8}. Here,
Disjoint Sets have any common element. set A and set B are disjoint sets.
Venn Diagram
Venn Diagram
Example -
U = {1,2,3,4,5,6,7,8,9,10} 8
7
Set A = {1,2,3,4}
1 3 5
Set B = {3,4,5,6}
2 4 6
Union, Intersection and Complement
9 10
● A U B = {1,2,3,4,5,6}
● A ᑎ B = {3,4}
● A’ = {7,8,9,10}
Formula for Union/ Intersection for number of elements
Union
Intersection
n(A ∩ B) = 𝜙
Difference
n(A - B) = n(A)
Mutually Exclusive and Disjoint Events
Mutually Exclusive Events
In a six-sided die, the events '1', '2', '3', '4', '5' and '6' are mutually
exclusive events. We cannot get any of these events together at the
same time when we threw one die.
The two events are said to be Mutually The two events are said to be Mutually
Exclusive and Exhaustive when the sum Exclusive and Exhaustive when the sum of
of their probabilities = 1. their probabilities < `1.
Eg - The event of Head or Tail when you Eg - In a six-sided die, the events '2', and '6'
toss a coin are Mutually Exclusive and are M.E. events but NOT EXHAUSTIVE as
Exhaustive. Thus - there are other outcome also that can
come up.
P (H) + P (T) = 0.5 + 0.5 = 1 P (2 and 6) = 0.33 < 1
Bayes Theorem
Bayes Theorem
=((0.7)*(0.1))/0.4 =0.175
Confusion Matrix for Bayes Theorem
What is the probability that a person selected is a
Girl knowing the person plays cricket?
Cricket Other Games
P(A) = probability of selecting a Girl =(12+40)/
(12+40+35+10) = 0.536
Boy
P(B) = probability of playing cricket
=(35+12)/(35+10+12+40) = 0.485
Event A - Rolling an Odd number {1,3,5} and Event B - Rolling multiple of 3 {3,6}. Thus -
P(A)= 3/6 = 1/2 and P(B) = 2/6 = ⅓ and P(A ∩ B) =1/6 i.e. {3}
Since P(A) and P(A|B) are equal to 0.5 - means that the occurrence of Event B does not
impacted the probability of occurrence of event A.
A B
Using multiplication Rule -
(AUB)’ = A’ ∩ B’
LHS RHS
Term Definition
Experiment An activity whose outcomes are not known is an experiment. Every experiment has a few favorable outcomes and
a few unfavorable outcomes.
Random A random experiment is an experiment for which the set of possible outcomes is known, but which specific
Experiment outcome will occur on a particular execution of the experiment cannot be said prior to performing the experiment.
Eg - Tossing a coin, rolling a die, and drawing a card from a deck are all examples of random experiments.
Trial The numerous attempts in the process of an experiment are called trials. In other words, any particular
performance of a random experiment is called a trial. For example, tossing a fair coin 2 times are 2 trials.
Event An event is an outcome or a set of outcomes that we are interested in. It can be a single outcome or a combination
of outcomes.
Random Event An event that cannot be easily predicted is a random event. For such events, the probability value is very less.The
formation of a rainbow during the rain is a random event.
Terminology related to Probability
Term Definition
Sample Space The sample space represents the set of all possible outcomes in an experiment or a random process. It is
denoted by the symbol "Ω" or sometimes "S".
Outcome An outcome is a specific result that can occur in an experiment or a random process. It is a member of the
sample space.
Possible Outcome The list of all the outcomes in an experiment can be referred to as possible outcomes. In tossing a coin, the
possible outcomes are heads or tails.
Equally likely An experiment in which each of the outcomes has an equal probability, such outcomes are referred to as
Outcomes equally likely outcomes. In the process of rolling a six-faced dice, the probability of getting any number is equal
to 1/6.
Probability Probability is a numerical measure that quantifies the likelihood of an event occurring. It is a value between 0
and 1, where 0 indicates impossibility and 1 indicates certainty.
Terminology related to Probability
Term Definition
Probability A probability distribution describes the probabilities of all possible values that a random variable can take.
Distribution It can be represented by a table, a graph, or a mathematical function.
Independent Independent events are events where the occurrence of one event does not affect the probability of the
Events other event occurring. The probability of two independent events happening together is the product of their
individual probabilities.
Dependent Dependent events are events where the occurrence of one event affects the probability of the other event
Events occurring. The probability of two dependent events happening together is the product of the probability of
the first event and the conditional probability of the second event given the first event.
Complementary The complementary event of an event A is the event that A does not occur. The probability of the
Events complementary event is equal to 1 minus the probability of the original event. For an event with probability
P(A), its compliment is P(Ā) i.e. P(A) + P(Ā) = 1.
Terminology related to Probability
Term Definition
Mutually Two events such that the happening of one event prevents the happening of another event are referred to
Exclusive Events as mutually exclusive events. In other words, two events are said to be mutually exclusive events, if they
cannot occur at the same time. For example, tossing a coin can result in either heads or tails. Both cannot
be seen at the same time.
Conditional Conditional probability is the probability of an event occurring given that another event has already
Probability occurred. It is denoted as P(A|B), where A and B are events. Thus P(A|B) means Probability of A knowing
B has already occurred. This is alao known as Bayes Theorem.
Expected Value The expected value of a random variable is the long-term average value that would be obtained if the
random experiment or process were repeated many times. It is also known as the mean or the average.
Random Variable and Distributions
Random Variable Concept
Random Variable is
Random Variable has a probability law - a rule that assigns probabilities to different values of random variable. This
probability law is called Probability Distribution of the Random Variable. We usually donate Random Variable with
capital letter let’s say X. Then Probability Distribution of X is donate by P(X).
Random Variable - Example of rolling of 2 dice Example
Outcomes when you roll 2 dice
Histogram of rolling dice Concept
Random Variable - Example of flipping 4 coins Example
Probability Distribution of Heads and Tails when flipping a coin 4 times.
A probability distribution is a statistical function that describes the likelihood of obtaining all possible
values that a random variable can take. In other words, the values of the Random Variable vary based
on the underlying probability distribution. We usually write Random Variable with capital letter like X.
Then Probability Distribution of X is donate by P(X).
Probability Distribution - Types Concept
Discrete Probability Distribution Concept
The values of the Continuous PD can be measured and not counted. It will
take infinite amount of time to count all the outcomes of a continuous
variable.
Continuous Probability Distribution - Example Concept
50 kms
For continuous variables, we can become more precise (or sharp) but we cannot count the exact distance,
age or time just the way we count discrete variables. That is why it is a continuous variable.
In other words, we can always find another data point between 2 data points of an infinite variable eg -
between 50 kms and 51 kms there is 50.5 kms. Further between 50 kms and 50.5 kms we can have 50.25
kms and so on.
Continuous Probability Distribution - Representation Concept
Continuous Probability Distribution - Example Concept
Random Variable Concept
For flipping coin example following is the Cumulative distribution function (Discrete Variable)
2 HHTT, TTHH, HTHT, THTH, HTTH, THHT 6/16 = 0.3750 0.6875 2*(0.3750) = 0.75
1) Expected Value
X 2 3 4 5 6 7 8 9 10 11 12
P(X=x) 1/36 2/36 3/36 4/36 5/36 6/36 5/36 4/36 3/36 2/36 1/36
● Variance of Random Variable is the Expected Squared Deviation of the random variable from its Mean
(Expected Value).
● This is similar to that of the Variance of a data set or a population
● Probabilities of the values of the random variable are used as weights in the computation of the
expected squared deviation from the mean of a discrete random variable
● The definition of the variance follows. As with a population, we denote the variance of a random
variable by 𝞂 2.
Variance - Example for the roll of 2 dice Example
2) Variance =
X 2 3 4 5 6 7 8 9 10 11 12
P(X=x) 1/36 2/36 3/36 4/36 5/36 6/36 5/36 4/36 3/36 2/36 1/36
E(X2)= ∑x2i*[P(X)] = 22 x(1/36)+32 x(2/36) + 42 x (3/36) +52 x (4/36) +62 x (5/36) +72 x (6/36) +82 x (5/36) +92 x (4/36) +102 x
(3/36) +112 x (2/36)+122 x (1/36) =
Q - A striker in a game of soccer can shoot with the probability of 0.7. Find the Mean and Variance of the striker in
the game?
Here p = 0.7 and q = 0.3; Mean = E(X) = 1*(0.7) + 0*(0.3) = 0.7; Variance = (0.7)*(0.3) = 0.21
Q - An AI bot has a 0.9 probability of correctly predicting the outcome of an event. What is the Mean and Variance
of the AI bot in prediction?
Here p = 0.9 and q = 0.1; Mean = E(X) = 1*(0.9) + 0*(0.1) = 0.9; Variance = (0.9)*(0.1) = 0.09
Binomial Distribution Concept
The Binomial distribution represents the probability for 'r' successes of an experiment in 'n' trials, given a success
probability 'p' for each trial at the experiment.
An X (Random Variable) that counts the number of ‘Successes’ in multiple Independent, identical Bernoulli trials is
called a Binomial Random Variable. Thus in Binomial Distribution the experiment is repeated multiple times.
In a single experiment when n = 1, the Binomial distribution is called a Bernoulli distribution.
Q - If a coin is tossed 10 times, use binomial find the probability of: (a) Exactly 4 heads (b) At least 7 heads.
Solution - No of trials = n = 10; Probability of head: p = 1/2 and probability of tail, q = 1/2
P(x =4) = 10C4 p4 q10-4 = (10!/ (4!x 6!)) × (½)4× (½)6 Use COMBIN in excel to get the value of )
1) On a toll, a car arrives at a mean rate of 10 per min. What is the probability of arrival of 15 cars in 1 minute.
2) 2% of the phones manufactured by Samsung are defective, what is the probability that 8 phones turn
defective in a sample of 200.
3) Mc’donalds restaurant has 200 customers coming every evening. What is the probability that on a day 220
customers turn up?
The Normal Distribution, also known as the Gaussian distribution, is the most important probability distribution in
statistics for independent, random variables. Most people recognize its familiar bell-shaped curve in statistical reports.
The data is symmetrically distributed with no skewness. When plotted on a graph, the data follows a bell shape, with
most values clustering around a central region and tapering off as they go further away from the center.
Empirical Rule or 3 Sigma Rule or the 68-95-99.7 rule applies to Normal curve. It states that -
● Data points are referred to as x in a normal distribution, they are called z or z-scores in the
z-distribution. A z-score is a standard score that tells you how many standard deviations
away from the mean an individual value (x) lies`
Permutations and Combinations
Fundamentals Principle of Counting
What is the Fundamental Principle of Counting?
The principle states that - if an event can occur in m different ways, and another event can
occur in n different ways, then the total number of occurrences of the events is m × n.
Books/
Home Office Park Car
Places
2) What are the different combination of selecting 2 different letters from a,b,c,d.
ab, ac, ad, bc, bd, cd.
In Nutshell -
a) In Permutation - ‘ab’ and ‘ba’ are not same as the ORDER is important
b) In Combination - ‘ab’ and ‘ba’ are same. i.e. order is NOT important
Use of Permutation and Combination
PERMUTATION is used for the list of data (where the order of the data matters)
COMBINATION is used for a group of data (where the order of data doesn’t matter)
n
Total Permutations = Pr
n = 4 and r = 4 = 4!/ (4-4)!
For the word - AGAIN - calculate the number of words which can be made using all the
letters of the word AGAIN?
Words that can be created using 5 letters A,A,G,I,N A,I,A,G,N G,A,A,I,N I,A,A,G,N N,A,A,G,I
A,A,G,N,I A,I,A,N,G G,A,A,N,I I,A,A,N,G N,A,A,I,G
Total Permutations A,A,I,G,N A,I,G,A,N G,A,I,A,N I,A,G,A,N N,A,G,A,I
= n Pr where n = 5 and r = 5 A,A,I,N,G A,I,G,N,A G,A,I,N,A I,A,G,N,A N,A,G,I,A
A,A,N,G,I A,I,N,A,G G,A,N,A,I I,A,N,A,G N,A,I,A,G
Now since there are 2 A in the word A,A,N,I,G A,I,N,G,A G,A,N,I,A I,A,N,G,A N,A,I,G,A
A,G,A,I,N A,N,A,G,I G,I,A,A,N I,G,A,A,N N,G,A,A,I
we will divide by 2! Because the A,G,A,N,I A,N,A,I,G G,I,A,N,A I,G,A,N,A N,G,A,I,A
position of the 2 A’s does not make a A,G,I,A,N A,N,G,A,I G,I,N,A,A I,G,N,A,A N,G,I,A,A
difference in the arrangement. Hence A,G,I,N,A A,N,G,I,A G,N,A,A,I I,N,A,A,G N,I,A,A,G
the final answer = 5!/(5-5)!*2! = 60 A,G,N,A,I A,N,I,A,G G,N,A,I,A I,N,A,G,A N,I,A,G,A
A,G,N,I,A A,N,I,G,A G,N,I,A,A I,N,G,A,A N,I,G,A,A
Examples of Permutations and Combination
In how many ways 4 letter words (no meaning needed) can be drawn from the word -
'NUMBERS'?