You are on page 1of 38

Week 4: Introduction to Probability

Unit 1: Introduction to Probability


Introduction to Probability
Introduction

▪ There are many times in modern life where


you would like to predict the likely outcome of
an event or series of events.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Introduction to Probability
Introduction – More complex examples

event/s
probability =
number of
outcomes

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


Introduction to Probability
Some symbols

Here are some commonly used symbols and


conventions:
▪ P(A) – The probability of event A
− The probability of throwing a six with a die – P(6)
▪ P(A ∩ B) – The probability of event A and B
− The probability of throwing 2 sixes – P(6∩6)
▪ P(A ∪ B) – The probability of event A or event B
− The probability of choosing one card from a standard
deck and getting either a Queen of Hearts or King of
Hearts
▪ P(A|B) – The probability of A given prior event B
− The probability of being diagnosed with cancer given
that the patient is a smoker

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


Introduction to Probability
What is probability?

0 0.25 0.5 0.75 1

Will Not Unlikely May or Likely Will


happen may not happen
happen

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Introduction to Probability
How do I calculate the probability of an event?

Calculate all possible outcomes for an event


(the “sample space”).
▪ For example, there are 6 possible events
(outcomes) when throwing one die:
▪ S = {1,2,3,4,5,6}

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


Introduction to Probability
How do I calculate the probability of an event?

▪ To calculate the probability of an event you use the


following formula:
𝑇𝑜𝑡𝑎𝑙 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑂𝑢𝑡𝑐𝑜𝑚𝑒𝑠 𝑓𝑜𝑟 𝑡ℎ𝑒 𝐸𝑣𝑒𝑛𝑡
𝑃(𝐸) =
𝑇𝑜𝑡𝑎𝑙 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑂𝑢𝑡𝑐𝑜𝑚𝑒𝑠 𝑖𝑛 𝑡ℎ𝑒 𝑆𝑎𝑚𝑝𝑙𝑒 𝑆𝑝𝑎𝑐𝑒

▪ What is the probability of throwing a six?


– P(E) = 1/6 = 0.16 or 16%
▪ What is the probability of throwing an even number?
– P(E) = 3/6 = 0.5 or 50%

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


Introduction to Probability
How do I calculate the probability of an event?

Music style # of people who prefer


Rock 20
Disco 10
Hip Hop 15
Reggae 25
Classical 30
Total 100

If you choose a random person, what is the likelihood that they like classical music?
P(E) = Frequency for classical / Total frequencies in table
P(E) = 30/100 = 0.3

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


Introduction to Probability
Summary

▪ You can calculate the likelihood of an event or series


of events using probability.
▪ You need to understand all possible outcomes in the
“sample space” and the particular event or group of
events you are analyzing.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2019 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/copyright for additional trademark information and notices.
Week 4: Introduction to Probability
Unit 2: Conditional Probability
Conditional Probability
Introduction

▪ It often happens that the probability of an event is


conditional on a previous event.
▪ If you have a bag of snooker balls, you can calculate
the probability that you will pull out a red one or a
green one.
▪ However, what is the probability that you will pull out
a second red or a second green?

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Conditional Probability
What is conditional probability?

▪ “Conditional probability” is a measure of the probability


of an event given that another event has occurred.
▪ There are 15 red balls out of a total of 22 balls.
– Therefore, the probability P(E) of taking out a red ball is:
P(E) = 15/22 = 0.68
▪ However, now you have reduced the number of red balls
to 14.
– Therefore, the probability of the next random ball being
red is slightly less:
P(E) = 14/21 = 0.66

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


Conditional Probability
Combining probabilities

▪ The upright symbol | is used to indicate conditional


probability.
▪ For example:
– P(B|A) means the conditional probability of B given A.
▪ This is calculated in the following way:
– P(B and A) = P(A) * P(B|A)
▪ So the probability of getting 2 red balls is:
– P(B and A) = 15/22 * 14/21 = 210/462 = 0.4

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


Conditional Probability
Pulling 2 aces

▪ What is the probability of pulling an ace from a pack of cards having


already picked out an ace?
▪ There are 52 cards in a standard pack of cards and 4 are aces.
Therefore the simple probability of picking out the first ace is 4/52:
– P(A) = 4/52 = 1/13 or 7.7%
▪ Once this ace has been picked out there are only 3 other aces left and
51 cards in total. Therefore the simple probability of drawing the
second ace is 3/51:
– P(B|A) = 3/51 = 5.9%
▪ However we want to combine these to calculate the combined
probability of pulling two aces – P(A and B) This can be done by
multiplying together the above simple probabilities:
– P(A and B) = P(A) * P(B|A) = 4/52 * 3/51 = 12/2652 = 1/221 or 0.45%

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Conditional Probability
Desserts

P(B|A) = P(A ∩ B)
P(A)

▪ 80% of your team like Tiramisu.


▪ 20% like Tiramisu and Sticky Toffee Pudding.
▪ What is the probability of team members liking Sticky
Toffee pudding given that they like Tiramisu?

P(STP|T) = P(T ∩ STP) = 0.2 = 0.25 or 25%


P(T) 0.8

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


Conditional Probability
Summary

▪ Using probability you can calculate the likelihood of an


event or series of events.
▪ You need to understand all possible outcomes in the
sample space and the particular event or group of events
you are analysing.
▪ Events which are conditional upon each other can be
combined to calculate probabilities.
▪ By rearranging the formula, you can calculate the
probability of more than one dependent event, P(A and B),
as well as the probability of one event being contingent on
a second event, P(B|A).

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2019 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/copyright for additional trademark information and notices.
Week 4: Introduction to Probability
Unit 3: Understanding Bayes’ Theorem
Understanding Bayes’ Theorem
Introduction

▪ In the 18th century, Thomas Bayes came up


with an approach to how statistical probabilities
should change in response to new evidence.
▪ Bayes’ theorem provides us with the ability to
update our beliefs based on prior knowledge of
factors that might be related to the event.
▪ In this lesson, you should remember that
P(A|B) means the probability of outcome ‘A’
given evidence ‘B’.
− For example, the probability of getting lung
cancer, given that the person is a smoker:

P(Lung Cancer | Smoker)

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Understanding Bayes’ Theorem
Where can we use Bayes’ theorem?

What is the likelihood that a You have developed an app to review What is the likelihood of
CEO of a stock market listed travel expense claims, after an audit people who work
company will be fired, given found that 3% of them contain errors. outdoors without a hat
that the company’s share ▪ The app finds errors in 94% of the examples getting skin cancer, given
price underperforms its picked up in the audit and in 8% of the they work in the UK?
competitors’ by more than claims with no errors.
10% over a year? ▪ What is the likelihood of there actually being
an error, given the expense claim has been
marked as such by your app?
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3
Understanding Bayes’ Theorem
Medical test example

▪ We know that a certain % of the population will get


lung cancer, but we want to know how that is affected
by prior conditions like drinking, smoking, or lack of
exercise.
▪ Bayes’ theorem allows us to calculate the likelihood
(probability) of someone getting cancer given that
they smoke.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


Understanding Bayes’ Theorem
Bayes’ theorem – The formula

P(A|B) = P(B|A) P(A)


P(B)

▪ P(A|B) is the probability of event A (such as ‘cancer’)


given B (if we know the person is a smoker).
▪ P(B|A) is the probability of B given A.
▪ Therefore, the formula calculates the probability of
event A, given the prior information we have about
event B.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Understanding Bayes’ Theorem
What’s the probability of getting cancer from smoking?

Lets assume that the prior probabilities are:


▪ 4% of the population have some form of cancer
▪ 20% of the population smoke
▪ 60% of people with cancer smoke,
i.e. P(Smoker|Cancer)

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


Understanding Bayes’ Theorem
What’s the probability of getting cancer from smoking?

P(A|B) = P(B|A) P(A)


P(B)

▪ The probability of the evidence conditional on the hypothesis –


probability of being a smoker given you have cancer:
P(B|A) = 0.6
▪ The prior probability of the hypothesis – having cancer:
P(A) = 0.04
▪ The prior probability of the evidence – simple prior probability
of being a smoker:
P(B) = 0.2

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


Understanding Bayes’ Theorem
What’s the probability of getting cancer from smoking?

We will use S for smoker and C for cancer:

P(C|S) = P(S|C) x P(C) = (0.6 x 0.04) = 0.12 (12%)


P(S) 0.2

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


Understanding Bayes’ Theorem
Summary

▪ You can use Bayes’ theorem to allow probabilities to be


re-evaluated based on new evidence.
▪ Bayes’ theorem allows you to evaluate the likelihood of
an event based on the occurrence of a prior event.
▪ The formula for Bayes’ theorem:
VENN DIAGRAM!
P(A|B) = P(B|A) P(A)
P(B) A B

Both A & B

▪ The probability of A occurring is calculated based on


the relevant event B, which has occurred.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2019 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/copyright for additional trademark information and notices.
Week 4: Introduction to Probability
Unit 4: Examples of Bayes’ Theorem in Practice
Examples of Bayes’ Theorem in Practice
Reminder

▪ Let’s remind ourselves of the formula:

P(A|B) = P(B|A) P(A)


P(B)

▪ That is … what is the likelihood of event A Event A Event B


given the evidence we have of B.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Examples of Bayes’ Theorem in Practice
Example 1 – Watching the weather!

▪ You look out of the window and see clouds


everywhere. How do you calculate the likelihood that
this will turn into rain later?
That is P(R|C)
▪ You know from old weather data that rainy days start
off cloudy 70% of the time:
That is P(C|R) = 0.7
– This is the simple probability of the day having
started cloudy earlier, given rain later in the day.
▪ Yet, 50% of days start off cloudy:
That is P(C) = 0.5
▪ This month (June) normally only has a few cloudy days
(3 days in the month, i.e. 10%):
That is P(R) = 0.1
▪ What is the likelihood of rain?
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3
Examples of Bayes’ Theorem in Practice
Example 1 – Watching the weather!

P(A|B) = P(B|A) P(A)


P(B)

P(Rain|Cloud) = P(Cloud|Rain) P(Rain)


P(Cloud)

▪ We know:
P(Cloud|Rain) = 0.7
P(Rain) = 0.1 (likelihood for June)
P(Cloud) = 0.5
▪ Therefore, using Bayes’ theorem, the probability of getting
rain if it’s cloudy in June is …
P(Rain|Cloud) = 0.7 x 0.1 = 0.14 or 14%
0.5
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4
Examples of Bayes’ Theorem in Practice
Summary

▪ Calculating probabilities is very useful, but it is


important to be able to factor in information that will
relate to and affect the probability.
▪ Bayes’ theorem allows you to evaluate the likelihood of
an event based on the occurrence of a prior event.
▪ This was illustrated with two very simple examples.
However, Bayes’ theorem can be used in much more
interesting and complex ways, such as calculating the
likelihood of false positives on a health screening test.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2019 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/copyright for additional trademark information and notices.

You might also like