Powered By Blogger

Tuesday, September 15, 2015

Conditional Probability and Bayes ‘Theorem: An Application of Coding by Excel







When we are willing to apply the ideas of the statistics in the fields of engineering, sometime classic probabilities or fre­quen­tist sta­tis­tics, which deals with things like nor­mal dis­tri­b­u­tion, bell curves, and so on, does not as well as work so that we need another idea of the statistics, which is named Conditional probability or Bayes’ theorem. Bayesian probability theory is now commonly employed (oftentimes with stunning success) in many scientific disciplines, from astrophysics to neuroscience. It is most often used to judge the relative validity of hypotheses in the face of noisy, sparse, or uncertain data, or to adjust the parameters of a specific model.
The purpose of this article is to solve some types of complicate problems by using conditional probability and the methodology stated in article of “EMFPS: How Can We Get the Power Set of a Set by Using of Excel?” posted on link: http://emfps.blogspot.com/2012/08/emfps-how-can-we-get-power-set-of-set.html
An example has been analyzed and solved by this method.





Introduction
Conditional probability is referred to probability of an event or outcome based on the occurrence of a previous event or outcome.  Conditional probability is calculated by multiplying the probability of the preceding event by the updated probability of the succeeding event.
Consider the events of “A” and “B”. The probability of event B is calculated by below formula, if event A was already occurred:

 P (B|A) = P (AÇ B) /  P (A)   ,  P (A) > 0

Bayes’ rule really involves nothing more than the manipulation of conditional probabilities. Bayesian probability theory provides a mathematical framework for performing inference, or reasoning, using probability. Bayesian logic is a branch of logic applied to decision making and inferential statistics that deals with probability inference: using the knowledge of prior events to predict future events. Bayes' theorem provided, for the first time, a mathematical method that could be used to calculate, given occurrences in prior trials, the likelihood of a target occurrence in future trials. According to Bayesian logic, the only way to quantify a situation with an uncertain outcome is through determining its probability.

Bayes' Theorem is a means of quantifying uncertainty. Based on probability theory, the theorem defines a rule for refining a hypothesis by factoring in additional evidence and background information, and leads to a number representing the degree of probability that the hypothesis is true.

According to Andrew Anderson (2012), Bayesian analy­sis is the use of con­di­tional or evi­den­tial prob­a­bil­i­ties. It looks at what you know of the envi­ron­ment and past knowl­edge, and allows you to infer prob­a­bil­i­ties based off of that data.

Here is an example that shows us the difference between classic probability and Bayesian approach:

In a company, the pop­u­la­tion of females is 32%, so that means that if I select some­one at ran­dom from my office, I have a 32% chance of pick­ing a female. The chances are purely based on the total prob­a­bil­ity. The Bayesian approach is to rely on past knowl­edge and then adjust accord­ingly. If I know that 25% of my office is male, and I grab a per­son, then I know that I have a 75% chance of pick­ing a female.

So is it 32% or 75%? Both are cor­rect answers depend­ing on what ques­tion you are really ask­ing, but both look at things dif­fer­ently.

Now, let me bring a complicate case and analyze it by using of the method posted on link: http://emfps.blogspot.com/2012/08/emfps-how-can-we-get-power-set-of-set.html

Case: Assume we have a box including 7 green balls and 5 red balls. We reach in and pull out 4 balls. If there is the probability of P (A) that 3 balls from 4 are green then, what is the probability of fourth ball that will be red?

Solution:

Conceptualize: Imagine we have two events A and B in which they are defined as follows:
A = event of 3 green balls from 4 balls

B = event of one red ball from 4 balls
Categorize: We should calculate P (B|A) by using of below formula:


 P (B|A) = P (AÇ B) /  P (A)   ,  P (A) > 0
 

How can we calculate P (AÇ B) and P (A)? In this case, I used from coding system in excel. In fact, I gave to any random ball into box a number. Therefore, we have 12 balls which each one has a number of 1 to 12. Since we have 4 balls from 12, I obtained all combinations or binomial [12, 4] or C (12, 4) because we have not any repetition and also the replacement does not matter, if we assign to any random ball a number. Finally, I calculated above probabilities step by step as follows: 

Analyze: Let me start step by step this method by using of excel:

Ø  Type “c” into cell A1 in your spreadsheet

Ø  Type into cell A2 the number of choices which is 4

Ø  Type into cells of: 

A3 = 1

A4 = 2

A5 =3

A6 =4

A7 =5

A8 = 6

A9 =7

A10 =8

A11 =9

A12= 10

A13= 11

A14 = 12

Ø  Now, we can run macro from VB code written by Myrna Larson to obtain all combinations. You can find this code on link: http://emfps.blogspot.com/2012/08/emfps-how-can-we-get-power-set-of-set.html
There are two methods to solve this problem as follows:

Method of event A:

Ø  Type formula:  =IF(A1<=7,1,0) on cell F1. Because we have 7 green balls

Ø  Draw above formula for G1, H1 and I1 and also draw down all four cells for 495 columns

Ø  Type formula: =IF(SUM(F1:I1)=3,1,0) on cell J1 and formula: =IF(SUM(F1:I1)>=3,1,0) on cell K1 and also draw down all two cells for 495 columns

Ø  On cell J496 type formula: =SUM(J1:J495) and on cell K496 type formula: =SUM(K1:K495)

Ø  Now, we can calculate the probabilities as follows:

Ø  P (AÇ B) = cell J496 / 495 = 0.353535354

Ø  P (A) = cell K496 / 495 = 0.424242424

Ø  P (B|A) = 0.83333333
Method of event B:

Ø  Type formula:  =IF (A1<=5, 1, 0) on cell F1. Because we have 5 red balls

Ø  Draw above formula for G1, H1 and I1 and also draw down all four cells for 495 columns

Ø  Type formula: =IF(SUM(F1:I1)=1,1,0) on cell J1 and formula: =IF(SUM(F1:I1)<=1,1,0) on cell K1 and also draw down all two cells for 495 columns

Ø  On cell J496 type formula: =SUM(J1:J495) and on cell K496 type formula: =SUM(K1:K495)

Ø  Now, we can calculate the probabilities as follows:

Ø  P (AÇ B) = cell J496 / 495 = 0.353535354

Ø  P (A) = cell K496 / 495 = 0.424242424

Ø  P (B|A) = 0.83333333

In the next articles, I will bring you the examples of real world in the field of engineering (Turbo molecular pumps) and also in the field of strategic management (External Real Forces and Pseudo-Forces to Design a Strategic Plan).

To be continued……..





No comments:

Post a Comment