Probability Notes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

Probability

what is probability
probability is the branch of mathematics
concerning numerical descriptions of how likely
an event is to occur

In other words probability is a measure of


likeliness of something happening
Given n observations of an event it denotes the
proportion of observations where a given event
occurs

p E of outcomes in which event occurs


total possible of outcomes

The probability of an event is always


between O and 1

i e Favorable outcomes
probability
Total outcomes

as favorable outcomes are always less than


to total outcomes so
or equal
OE PCE E I
ex marbles
number of red
PCred
Tze total no of
marbles
É sample space
p blue A
number of blue marbles
6000 f total no of
marbles
sample space

Probability Terminology
Experiment An Experiment or trial is any

Procedure that can be infinitely repeated and


has a well defined set of possible outcomes
known as sample space

Random Experiment An Experiment is said to

be random if it has more than one possible


outcome and the outcome cannot be predicted

Experiment is deterministic if it has only


one outcome
Outcome An outcome is a possible result of
an experiment or trial
Sample space All the possible outcomes of
an experiment is sample space
Event An event is a set of outcomes of an

experiment whose probability has to be calculate

Simple Event It has a single sample point


Compound Event 4 has more than one

sample point
Sure Event It will happen for sure i e

PCE I

Impossible Event It will not happen


i e PIE O

Probability is a measure of how likely an

event is So if it is Got chance that it


will rain tomorrow the probability of
outcome it rained for tomorrow is 0.6

Ex
1 Probability experiment Roll a die
outcome 933
Sample space 1 2 3,4 5,63
Event Die is Even 2,4 63

P Even ten 214,63


ten 1,2 3,4 5,63
I
2 Probability Experiment Deck of cards
sample space 3 total 52 Cards

Event card drawn is face card 12 face cards

E face card
p
Iz
probability can be thought in terms of sets
and Venn diagrams
ex's

B A B
A
Joint set Dis Joint set
we will see few of the Events
1 Complimentary Event
2 Dependent Event
3 Independent Event
4 Mutually Exclusive Event
5 Exhaustive Event

Complimentary Event The complement of an

Event is the subset of outcomes in the sample

space that are not in the event A complement

is itself an event

universal set
s sampte
AC space

A set A
Extent

The complement of an event A is denoted as


A or For Ac
An even and its complement are mutually
exclusive and exhaustive
ex A It rained
Ac It did not rain

PCAC L PCA

or p Cal PCA 7 1

Dependent Events Two are more events that


depend on one another are known as dependent
Events If one event is by chance changed
then another is likely to differ
ex Not paying power bill on time and having
your power cut off

Independent Events Independent events are

these events whose occurrence is not dependent


on any other event

ex If we flip a coin in the air and set the


outcome as Head then again if we flip the

coin but this time we set the outcome as


Tail In both cases the occurrence of both

events is independent of each other


Mutually Exclusive Events Two events are

said to be mutually exclusive if they cannot


occur at the same time or simultaneously
In other words mutually exclusive events are

considered disjoint events then the


of both probaboccurring
the lity
events at the

same time will be zero

P CAN B o
A B
Exhaustive Events A set of Events are called
exhaustive events if at least one of them

necessarily occurs whenever the experiment is

Performed Also the union of all these events


constitutes the sample space of the experiment

Eu
El

Es
EZ Ez
E U Ez UE UE UE S Sample space

ex On the toss of a coin event Heads and


event tail are mutually exhaustive events
Opp's in Favour n
I non favourable
favourable outcomes
outcomes
PCE
En
ODD'S Against
I I favourable
non favourable outcomes
outcomes
PCE

ex D Obp's in favour of an event E is 3

PCE Z
2 ODD's against an event E is y S

PCE
I
Algebra of Events
Consider two events A and B
Intersection Ants set of all elements common
to A and B

Union AUB Set of all elements belonging to


either A or B

Difference A B Elements belonging to A but


not to B

A and B are mutually exclusive or disjoint

if An 13 0

Union AUB The union of two sets A and B

Jit is denoted by AUB

AUB

A B
AFB
PC AUB PCA PIB P IAN B

of A and B are mutually exclusive then we

have p AUB p a PCB as PC AND o


Intersection Anb or A and B

A Intersection B is a set that contains elements


that are common in both sets A and B

A B

P ANB PIA PIB PC AUB

Difference A B

The Difference between two events A and B is


denoted by A B and this contains the elements
that are in A but not in B

A B

PCA B PCA PLAN B


Rules of probability

1 The probability of an event always lies between

0 and 1

OE PCE I I

ext On a di le roll

PCE 7
8
0

PCE EG
8 1

2 Summation of Probabilities of all events in


a sample space is 1 or probability of the

univeral set is 1

PCs 1
or

PCE I
EI
ex on a toss of a coin S H T

PCH I PIT
L
PCH PCT It 12 1
3 If E Ez Ez are mutually exclusive then
PCE UEzUE3 PCE PCEz PCE
ex on a toss of a coin

PCH UT 1
PCH PCT It I

4 Probability of not getting the event is 1


minus probability of getting the event
P not E I PCE

ex In the toss of a coin

p not H 1 PSH
I
t
L
On the roll of dice
P not getting 1 P 2 PC37 PS4 pls PCG
we know

p i
PS2 PC P a PI 5 P 167 1

p 2 Ps3 pea pls PCG 1 PCI

p not setting 1 1 Pc setting 1


5 For dis joint events A B
The probability of A or B is equal to

probability of A plus probability of B

A B

p one or both events


PC AUB P CA PCB

6 For Joint events A B

The probability of A or B is equal to

Probability of A plus probability B minus

probability of A and B

A B

PCanB
P AUB PCA PCB PLAN B
Types of probability
D Marginal Probability
2 Joint Probability
3 Conditional probability

probability It is the probability


Marginal
of an event happening such as Pla and it
can be mentioned as unconditional probability
It does not depend on the occurrence of another

event
ex The likelihood that a card is drawn from
a deck of cards is black
p black
362 12
and the probability that a card drawn is 7

p 7
72 43
both are independent events since the outcome

of another event does not condition the result


of one event
Joint probability A statistical measure that
calculates the likelihood of two events occurring
together and at the same point in time is called

Joint probability
i e let A and B be the two events joint
is the prob
probability bility
of event B occurring at
the same time that event A occurs

With replacement

A B

Joint probability
P Can B

ex Find the probability that the number three will


occur twice when two dice are rolled at the
same time
S 1 2,3 4,5 63
PCE 3 on diet Yg PCE
p E 3 on die 2
46 P Ez

P E N Ez PCE P Ez
txt
Ig
ex the likelihood that a card is black and
seven is equal to

p Black and seven


32
there are 2 Black 7 in a deck of 52 the
7 of clubs and 7 of spades

p Black
362 I
p seven
42 73

P Black xp seven
Ix Is
Black and Black seven
P seven p x p
Joint probability without replacement

A B
a

Joint probability
P Can B

P An B PCA x p BIA
t
probability of B
happening given A has

already happened
ex probability of drawing 2 cards from a deck
one after another without replacement
Firstspade card
Second Face card
Conditional probability
Probability of a conditional event is conditional

Probability
Conditional Event Denoted by AIB or Bla

Event A has to happen when B has already


E
happened
Event B has to happen when A already
f has

happened

PCA given B or p AIB probability of occurrence of


A given B has already happened
so here the sample space becomes B

B has already happened


a p so here

i e we want to find probability of A

happening within B which is nogthin but


n An B Inis P CAN B
p A B
NCB n s PCB
i PCA IB PC ANB
PCB

with regards to Independent events

P AIB PCA
as p la happening has no dependence on

PCB happening or not

but as AIB P PCA


p Iggy
PCB
i
P CAN B PCA x

for Independent events

If A B are Independent so are Act B

A BC Aca BC
i e

PCA n B I PCA PCB if A B are

PC NBC i p ca Lp independent
events

i e of the existence of B does not matter to


the existence of A then they are independent
ex If two students are asked to solve

a question The probability of one solving


the question is independent from the

Probability of the other solving it

Q1 Of A and B are mutually exclusive


events then and impossible
Ap Bg are

events as

Plan B
PCI a
Plea so as o

04 P 1
E P
Aj
B End
Plan P
PCB PCB

i plan B plan B

A B PCB
i.pl tp
E
Ppf PCAnB
n n

I
PCAnB
03 A contains 5 Red balls 4 blue balls
bag
and 3 green balls then find of Probability
of drawing Red ball given a blue ball was

already drawn without replacement


P CRIB P RNB
PCB

Ext
I

PIE PCF 0.35 PCE UF o 55


QU IF 0.40

find P EIF PCF E

PCEU F PCE PCF PCENF

PC Ent PIE PCF PCE UF


0.40 0 35 0 55

0 20

P Elf P Ent
PCF 835 7
PCF El PCE Nfl
PCE 8 I
05 A couple has 2 Children Find the probability
that both are boys if it is known that
1 one of them is a boy
2 the older child is a boy
s GG GB BG BB

C Here one needs to be boy so s GB BG BB


i
PC both boys ten BB
her GB BG BB

e Here the first child is already boy


so 5 2 BG BB

I P both boys ten BB


ten BG BB

Q If P Pz Pz Pn are probabilities that


Certain events happen then probability of
all of them simultaneously is
i
happening
Independent events then
P Pax Pzx xPn
2 None of them happening is

Independent events
l P x 1 P2 x 1 P x x I Pn

3 Atleast one of them happening is means

I none of them happening


1 Ci Pi x I P2 x l P x x i Pn

Q AaB are 2 independent events The

probability that both A AB occur is Yg


probability that none of them occur is 43
Find the Probability of occurrence of A
if PCA P PCB q
since independent Plan B PCA PCB
i Pq i g
I i p

i p g pg
i p E I 3
p q
I since PE
t
solution is either p tea f or
pit a 9 1
Q A problem of mathematics is given to 3
students whose chances of solving are

what is the that


f f a
t probability
the Problem is solved
Since problem of solving is given then
problem of not solving are

l
E l
5 rt

Problem of atleast one solving is


1 problem of not solving
I
Ex 3 3
3
if we want problem is solved exactly by 1

1 i
Ex 3 1
4 t I
4 x

1 E 1
5 4
2 3 3 Ex 3 2 3 4

L
Total Probability Theorem

E Ez E Ey

A
are y mutually
Exclusive and Exh
aus live events
v u
g g g y
then PCA PCE na PCEana PCE na

PCEyna

if there are n Events which are mutually


exclusive and exhaustive events
i Pla p Enna p Ezra t P Enna

but p Ale PLANE


PCE

i PLANE P E PCA ED
substituting

Total probability theorem


PCA PCE xp Al E PCE2 XP AI Ez t

PC En x P Cal En

for E Ez En which are mutually exclusive


and exhaustive events

chain rule for events


Also known product nice permits the
as
cal ulation
of any member of the joint distribution of
a set of random variables using only conditional
Probabilites For two random events A B
PLAN B P BIA PCA
Baye's theorem
If we want to find the probability of
event Ei given A has already happened
then
PCE la PCE n A
PCA

PCE in a
PCE PLATE PCE2 PIA

i PCE a PCE PCA Ei


PCE P A E PCEz PCA Ez t

Another way to think

E Ez E Ey

A
are y mutually
Exclusive and Exh
austive events
v u
g g g yn
then plate PCE na
PCE na PCEana PCE na

PCEyna
Baes theorem If A and B are two events
then the formula for the Bayes theorem is given
by
P AIB PCB A PCA where PCB 0
PCB
where PIA B is the probability of condition when
event A is occurring while event B has already
occurred

Bayes theorem Derivation

Bayes therein can be derived for events and


random variables using the definition of
probability conditi nal
from the definition of conditional probability
P Alis where
t.AE37 PCB to

where PCA o
Tia
iii
Here the joint probability plan B of both
Plan B P BMA
Plan B P Bla PCA
i P AIB PCAIBY.gg
PCB IA PCA where PCB 0

Q1 Balls 4 bags
UR 3R ZR
SG ga 76

Bag 1 Bag 2 Bags

41 You draw one ball find the probability


it is Red

p drawing a red ball

P selecting bag 1 xp fred I bas 1

P selecting bag 2 xp red bag 2

P Selecting bag 3 x p cred 1 bags

Ix Ig Ix 3 3 x
I
2 You draw a red ball find the probability

that it came from bag 2

p selected bag 21 red ball


P selecting bag 2 xp red I bas z

p drawing a red ball c from


total
Probability
theorem
Ix 3

Ix Ig Ix 3g Ix

49
3g I

Q2 modes of transport
Sonali metro a car with
goes by bus
Probabilities of 217 Y Y respectively
of the probability that she sees by bus

and reaches late to school is 3 she


8
and reaches is and
goes by metro late
f
she by and reaches late is
goes car
y
II Find the probability that Sonali
reached school late
PGonali Late
217 late
Bus
zi 3 3 t
Sonali Metro

LÉ txt t
Car
y
Ex I
late Bas x P Late bus
p P
PC metro xp late metro t

p car x p late car

3 3 txt Fx

If
2 Sonali reached school late find the

probability that she travelled by car

217 Bus at
Sonali Metro

4
Car
I I
probability Sonali sav and late É x
y
P Sonali car and late
p Sonali car Late
p late
p Sonali car ate
Fx I
4 3 4 8 4 8
16 56 16
23 56 32

Q Truth or lie

consider a student A whose probability to ten


the truth is and
3 tell a lie is
g
4 A rolls a die find the probability that he

reports a 6

P Sin
PCreports 6 PC truth x

p tie xp not size

Zx I Ex I

8 72
He rolls a die and reports a G find
the probability that it is actually G

Truth 16 P Guth XP sin


p
P reports a sin
Ix f

3 8 5 5
Zg
Q Biased coin

1 Fair coin 1 Biased coin


H T PCH 1 315

PCT 45
il find the probability of getting a head

PC head p fair coin x P head fair coin

PC head biased coin


p biased coin x

Ix t t
t x

2 find the probability that it was a biased


coin given head
P biased XP head I biased
p biased I head
p head
Ix

Q 9h loan defaulters older people make only


1 Yt Now the probability that someone defaults

on a loan is 0.184 Find the probability of


default on loan knowing that he is an old
Person older people make up only 0.87

P older people I loan default 1.47


0 014

PC loan default 0.184

p older people 0.87

0.008

p loan default older people

P AIB P BIA PCA


Bayer's theorem
p B
I P loan default older people

P older people loan default p loan default


P older People

O 014 X 0.184
0 008

0.322

Q Spam Assassin works by having users train the

system It looks for patterns in the words in

emails marked as spam by the user

For example it may have learned that word free

appears in 307 of the mails marked as spam ie

p Freel spam 0.30 Assuming It of non spam


mail includes the word free and 507 of all
mails received by the user are spam find the
Probability that a mail is spam if the word

free appears in it

Free spam 0.30


P 0 01
non spam I 1
P Free
spam o s
spam 507 i p non
P
0.5

p spam I free

method 1 to find the answer

P Spam free p free spam p spam


p free

To fail emails 100


emails so non spam emails so
spam
1
1997
free
3ft no free
free
no free
0 snails 49 emails
15mails 35 mails

15.5
i fetal free emails
free 5 0.155
p 1,5

p spam free 0
0.96774

method 2 to find answer

formic
P spam free
P spam p free I spam

p free spam p spam P free no spam p no spam

0 5 0.3

0 3 0 5 t 0 01 x o 5

0 I 5
0 I5 0 005

0 96774
Frequency tables and contingency tables

contingency table both categorical variables


frequency table one categorical variables

Contingency tables Also called cross tab or

two way tables summarize the relationship between


several categorical variables It is a special type

of frequency distribution table where two


are shown simultaneously vari bles
ex contingency table summarising 2 variables
an Default and Age cross tab

Age
Young middle Aged Old Total

Loan NO 5252 13689 19066

Defaults yes 1793 2426 60 4279


total joy 1611 0 190 23345

Now if we want to convert them into


we prob bilities
will divide each cell with total
which is 23345
i e 5252 0 225 so on
23345
Probabilities

Age
Young middle Aged Old Total

NO 0 225 0.586 0.005 0.816


Loan
Defaults Yes 0.077 01104 0.003 01184

Total 0.302 0 690 0.008 1.000

Marginal Probability
Probability describing a single attribute

Age
Young middle Aged Old Total

Loan NO 0 225 0.586

Defaults Yes 0.077 01104 0.003 01184

total 0.3oz o.no

ex
Marginal
01184 probability
P Yes
p old 0.008
Joint Probability
Probability describing a combination of attributes

Age
Young middle Aged Old Total

NO 0 225 0.586 0.005 0.816


Loan
Defaults Yes 0.077 01104 0.003 01184

Total 0.302 0 690 0.008 1.000

Joint
probability
ex

P yes and old 0 003

p no and young 0 225

Union probability
of happening of the event A or B
Probability
Age
Young middle Aged Old Total

NO 0 225 0.586 0.005 0.816


Loan
Defaults Yes 0.077 01104 0.003 01184

Total 0.302 0 690 0.008 1.000


es or old PC yes Plaid pees and old
0.184 0.008 0 003

0.189

Conditional Probability
It is ratio between joint probability and
marginal probability
P AIB PLAN B
PCB

Age
Young middle Aged Old Total

Loan NO 0 225 0.586

Defaults Yes 0.077 01104 0.003 01184

Total 0.302 0.690

ex person will not default


probability that a on

loan given he she is middle aged

p no middle aged PCno and middle aged


P middle aged

0.586 0.85
O G go
ex considering titanic data set in pandas

First do a cross tab between p class and


survived
import pandas as pd
as np
import humpy
as Sns
import seaborn

import matplotlib p plot as pit

df Sns load dataset titanic

cross tab d f L p class If survival


Pd
margins True

Survived 0 1 All

p class
I 80 136 216

2 97 87 184

3 372 119 491

All 549 342 891

This is a
contingency or frequency table

Cross tab dfl p class I df survival


p class Surv Pd
margins True margin names Tota

p class Suru
Survived 0 1 Total

Pclass
I 80 136 216

2 97 87 184

3 372 119 491

Total 549 342 891

To create marginal probability table


divide the variable Pclasssuru by total ie 89

pclasssurr probtable p class Suru 891


pclasssurr probtable

survived 0 1 Total

Pclass
I 0.0897 0.1526 0.2424

2 0.1088 0.0976 0 2065

3 0.4175 0.1335 0 5510

Total 0 6161 0 3838 1 0000

From this table we can find marginal Joint


union and conditional probability
ext p pclass1 0.2424
PCP class 2 and 0.0976
surgged

P P class 3 or not survived


to
p P class 3 p not survived
P P class 3 and not survived
0 5510 0 6161 0.4175
O 7496

P P class 3 not survived


PCP Class 3 and not survived
p not survived

0.4175
O 6161

0 6776
Probability tree
A probability tree is a picture indicating
probabilities and some conditional probabilities
for combinations of two or more events

One of the easiest ways to solve a probability


problem is to construct the probability tree and
read the answer

The steps to draw a probability tree are as

follows
1 Draw branches of the first set of outcomes
and write the individual probabilities along
the branches
2 Repeat this process for the remaining outcomes

3 multiply the values of probabilities of


branches conne ting
to set the likelihood of occurrence

of each outcome
outcome
Probability
8.5 Head
Node
T o s Tail
Branch
Generalized probability tree

PCBand A PCB x PCA IB


p AIB a

BpCaiB A p B and A PCB x PCA B

A p B and a pea xp Al B
A B and a x pea pi
A'lB P PCB
p p_P
Pla p not a

Conditional probability Bayes theorem

P Bla PCB XP AIB


PCA
P AIB x PCB
P AIB PCB PCA IBI x
PCB

Q Approximately It of women aged 40 so have

breast cancer A women with breast cancer

has a 90 t chance of a positive test from


a mammogram while a woman without has

a lot chance of a false positive result

11 what is the probability a woman has breast


cancer given that she had a positive result

o o
cancer I
woman o t
No cancer
09g O go

cancer t
p
p t cancer x Pf cancer

PG

0.9 0.01

0.9 0.01 0 99 011

0.083

Note since we are calculating cancer given test


positive we are considering the values associated
with test positive only

You might also like