# Bayes’ Theorem

Bayes’ Theorem formula, also known as Bayes’ Law, or Bayes’ Rule, is an intuitive idea. We adjust our perspective (the probability set) given new, relevant information. Formally, Bayes’ Theorem helps us move from an unconditional probability (what are the odds the economy will grow?) to a conditional probability (given new evidence, what are the odds the economy will grow?)

Suppose your daughter tells you that her friend is coming home tomorrow. Since you don’t know anything else, there is a 50% chance that the friend is a female. Now she tells you that her friend has long hair. With this additional information there are now more chances that the friend is a female. Bayes’ theorem can be applied in such scenarios to calculate the probability (probability that the friend is a female.)

A simple representation of Bayes’ formula is as follows:

**Example 1**

The following information is available regarding drug testing.

- 0.5% of people are drug users
- A test has 99% accuracy. 99% of drug users and 99% of non-drug users are correctly identified by it.

The problem question is to find the probability of being a drug user if you’ve tested positive?

The solution according to Baye’s theorem is as follows:

- P(pos|user)=0.99 (99% effective at detecting users)
- p(user)=0.005 the probability of a number of people being drug users
- p(pos)=0.01*0.995+0.99*0.005 = 0.0149 which is deduced from the following details: 1% chance of non-users, 99.5% of the population, to be tested positive, plus 99% chance of the users, 0.5% of the population, to be tested positive.
- P(user/pos) = 0.99*0.005/0.0149 = 0.33

The answer we arrive at is that there is only a 33% chance that a positive test is correct

In this example some information is available about the proportions of users versus non-users but in practice such information may not be available or determined.

**Example 2**

A company expects that there is a 5% probability that the economy will expand. Furthermore, there is a 90% probability that the company’s revenue will rise if the economy expands. If the economy does not expand, there is only 40% probability that company’s revenue will rise.

What is the probability that the economy has expanded given that the company’s revenue has risen.

We want to find out:

P (Economy Expansion | Company Revenue Rises) = P (EE | RR)

P(EE | RR) = P (RR | EE) * P(EE)/P(RR)

P (Economy Expansion) = P(EE) = 0.05

P (Revenue Rise | Economy Expansion) = P(RR | EE) = 0.90

P (Revenue Rise) = P(RR) = 0.05*0.90 + 0.95*0.40 = 0.425

P(EE | RR) = 0.90*0.05/0.425 = 0.106

If the company’s revenue has risen, then there is a 10.6% probability that the economy has expanded.

- Probability - Basic Terminology
- Two Defining Properties of Probability
- Empirical, Subjective and Priori Probability
- State the Probability of an Event as Odds
- Unconditional and Conditional Probabilities
- Multiplication, Addition and Total Probability Rules
- Joint Probability of Two Events
- Probability of Atleast One of the Events Occuring
- Dependent Vs. Independent Events in Probability
- Joint Probability of a Number of Independent Events
- Unconditional Probability Using Total Probability Rule
- Expected Value of Investments
- Calculating Variance and Standard Deviation of Stock Returns
- Conditional Expected Values
- Calculating Covariance and Correlation
- Expected Value of a Portfolio
- Variance and Standard Deviation of a Portfolio
- Bayes’ Theorem
- Multiplication Rule of Counting
- Permutation and Combination Formula

# R Programming Bundle: 25% OFF

**R Programming - Data Science for Finance Bundle**for just $29 $39.