Let's start by taking an example of a person going to a market. What do you think, what is the chance that he would get infected by a disease if he went to the market?
No definite answer! Do you know why?
It could depend on various factors likeWhat is the mode of transport?
How good is his/her immune system?
Does he have co-morbidities?
How many infections in the neighbourhood?
In short, Due to the random nature of the world around us
The study of this chance is the subject matter of Probability theory!
Experiments, Sample Spaces and EventsĀ¶
Let's check on some experiments and their outcomes,
Taking a blood Test, the result could be positive with a disease or not.
Experiment
: Blood Test
Outcome
: {positive, negative}
Experiment
: Going to the mall
Outcome
: {public transport, private}
So, what does an Experiment means.
ā ExperimentsĀ¶
An experiment
or trial
is any procedure that can be repeated infinite times and has a well-defined set of outcomes
ā Sample SpaceĀ¶
The set of all possible outcomes of an experiment is called the sample space
. The elements in a sample space are mutually exclusive
and collectively exhaustive
.
The elements/outcomes in the sample space are Mutually exclusive in the sense that no two outcome can happen at the same time for the experiment.
Similarly the elements are collectively exhaustive, i.e the sample space contains the complete set of outcomes for the experiment.
This is because although the outcome in every trial is uncertain but the set of outcomes is certain.
Lets look at some standard experiments :
Some Standard ExperimentsĀ¶
- Experiments involving coin tosses
- Experiments involving dice throw
- Experiments involving a pack of cards
The above experiments are having discrete outcomes,
Let's take an example of an Experiment with Continuous outcome.
Let's take an example of a dart board, wherever the dart strikes will be an outcome.
Thus, the Sample space would be defined as
$$ Ī© = \{ ( x,y) \; s.t. 0 ā¤ x, y ā¤ 1 \} $$
ā Events of an ExperimentĀ¶
Let take an experiment of two coin toses.
The Sample space for this experiment is
$$ Ī© = \{HH, HT, TH, TT\} $$
then, the event A : such that the first toss results in a head
is :
$$ A = \{HH, HT\} $$
Similarly event B : the event that both the toss result in tails
$$ B = \{TT\} $$
Thus
An event is a set of outcomes of an experiment. This set is a subset of the sample space
ā We say that event A has occurred if the outcome of the experiment lies in the set A. i.e even if at least one outcome lies in set A, we will say event A has occurred
This also mean Events are set, and we can apply set operations on the events.
Unions of EventsĀ¶
In an experiment of throw of two dice.
Event A
: the event that the first die show a 2
$$ A = \{(2,1), (2,2), (2,3), (2,4), (2,5), (2,6)\} $$
Event B
: the event that the second die show a 4
$$ B = \{(1,4), (2,4), (3,4), (4,4), (5,4), (6,4)\} $$
The the Union of event A and event B is defined as
$$ C=A \cup B = \{(2,1), (2,2), (2,3), (2,4), (2,5), (2,6), (1,4), (3,4), (4,4), (5,4), (6,4)\} $$
i.e the event that the first die shows a 2 or the second die shows a 4
import itertools
dice_values = list(range(1, 7)) # All Possible values for each die i.e 1, 2, 3...6
#Universal Set : i.e {{1,1}, (1,2)....(6,5), (6,6)}
all_throws = set(itertools.product(dice_values, repeat=2))
print("Universal set of two dice throws:", sorted(all_throws))
#Event A : the event that the first die show a 2
event_A = {throw for throw in all_throws if throw[0] == 2}
print("Event A:", event_A)
#Event B : the event that the second die show a 4
event_B = {throw for throw in all_throws if throw[1] == 4}
print("Event B:", event_B)
print("A union B:", event_A.union(event_B))
Universal set of two dice throws: [(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), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)] Event A: {(2, 4), (2, 1), (2, 3), (2, 6), (2, 2), (2, 5)} Event B: {(4, 4), (2, 4), (3, 4), (5, 4), (6, 4), (1, 4)} A union B: {(4, 4), (2, 4), (2, 1), (3, 4), (5, 4), (6, 4), (1, 4), (2, 3), (2, 6), (2, 2), (2, 5)}
Intersection of EventsĀ¶
Event A
: the event that the first die show a 2
$$ A = \{(2,1), (2,2), (2,3), (2,4), (2,5), (2,6)\} $$
Event B
: the event that the second die show a 4
$$ B = \{(1,4), (2,4), (3,4), (4,4), (5,4), (6,4)\} $$
Then the intersection of event A and event B is defined as
$$ D=A \cap B = \{(2,4)\} $$
i.e the event that the first die shows a 2 and the second die shows a 4
print("Event A:", event_A)
print("Event B:", event_B)
print("A intersection B:", event_A.intersection(event_B))
Event A: {(2, 4), (2, 1), (2, 3), (2, 6), (2, 2), (2, 5)} Event B: {(4, 4), (2, 4), (3, 4), (5, 4), (6, 4), (1, 4)} A intersection B: {(2, 4)}
Complement of EventsĀ¶
Event A
: the event that the first die show a 2
$$ A = \{(2,1), (2,2), (2,3), (2,4), (2,5), (2,6)\} $$
Event B
: the event that the second die show a 4
$$ B = \{(1,4), (2,4), (3,4), (4,4), (5,4), (6,4)\} $$
Then the intersection of event A and event B is defined as
$$ E=A^c = \{(2,4)\} $$
i.e the event that the first die doesn't shows a 2
print("Universal set of two dice throws:", sorted(all_throws))
event_A = {throw for throw in all_throws if throw[0] == 2}
print("Event A where the first die shows a 2:", sorted(event_A))
print("Complement of A :", sorted(all_throws-event_A))
Universal set of two dice throws: [(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), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)] Event A where the first die shows a 2: [(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6)] Complement of A : [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)]
Disjoint EventsĀ¶
Event A
: the event that the first die show a 1
$$ A = \{(1,1), (1,2), (1,3), (1,4), (1,5), (1,6)\} $$
Event B
: the event that the first die show a 2
$$ A = \{(2,1), (2,2), (2,3), (2,4), (2,5), (2,6)\} $$
Then the intersection of event A and event B is a NULL set ( $Ī¦$ )
It is not necessary that a disjoint set is made up of event A and $ A^c $ i.e they are complement of each other, as in the above case where $A āŖ B \neq Ī© $
ā Two events A and B are said to be disjoint if they cannot occur simultaneously i.e. $ A \cap B = \phi $
Similarly,
Pairwise Disjoint EventsĀ¶
Event A
: Both coin toss are Head
$$
A = \{HH\}
$$
Event B
: Both coin toss are Tail
$$ B = \{TT\} $$
Event C
: Both coin toss are complement of each other
$$ C = \{HT,TH\} $$
then,
$$ A ā© B = Ī¦ B \cap C = Ī¦ A \cap C = Ī¦ $$
ā The events $A_1, A_2, .... , A_n$ are said to be mutually disjoint or pairewise disjoint if $ A_i \cap A_j = \phi \:\:\: ā i, j \:\: s.t. \:\: i\neq j $
event_A = {throw for throw in all_throws if throw[0] == 1}
print("Event A where the first die shows a 1:", sorted(event_A))
event_B = {throw for throw in all_throws if throw[0] == 2}
print("Event B where the first die shows a 2:", sorted(event_B))
print("intersection of A and B:", event_A.intersection(event_B))
Universal set of two dice throws: [(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), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)] Event A where the first die shows a 1: [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] Event B where the first die shows a 2: [(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6)] intersection of A and B: set()
Partition of the sample spaceĀ¶
Event A
: Both coin toss are Head
$$
A = \{HH\}
$$
Event B
: Both coin toss are Tail
$$ B = \{TT\} $$
Event C
: Both coin toss are complement of each other
$$ C = \{HT,TH\} $$
then,
$$ A ā© B = Ī¦ B \cap C = Ī¦ A \cap C = Ī¦ $$
Also,
$$ A āŖ B āŖ C = Ī¦ $$
ā If the events $A_1, A_2, .... , A_n$ are mutually disjoint and $A_1 \cup A_2 \cup .... \cup A_n = Ī©$ then $A_1, A_2, .... , A_n$ are said to partition the sample space