08.10.2016 Views

Foundations of Data Science

2dLYwbK

2dLYwbK

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Generation <strong>of</strong> random numbers according to a given probability distribution<br />

Suppose one wanted to generate a random variable with probability density p(x) where<br />

p(x) is continuous. Let P (x) be the cumulative distribution function for x and let u be<br />

a random variable with uniform probability density over the interval [0,1]. Then the random<br />

variable x = P −1 (u) has probability density p(x).<br />

Example: For a Cauchy density function the cumulative distribution function is<br />

P (x) =<br />

∫ x<br />

t=−∞<br />

1 1<br />

π 1 + t dt = 1 2 2 + 1 π tan−1 (x) .<br />

Setting u = P (x) and solving for x yields x = tan ( π ( u − 1 2))<br />

. Thus, to generate a<br />

random number x ≥ 0 using the Cauchy distribution, generate u, 0 ≤ u ≤ 1, uniformly<br />

and calculate x = tan ( π ( u − 1 2))<br />

. The value <strong>of</strong> x varies from −∞ to ∞ with x = 0 for<br />

u = 1/2.<br />

12.4.10 Bayes Rule and Estimators<br />

Bayes rule<br />

Bayes rule relates the conditional probability <strong>of</strong> A given B to the conditional probability<br />

<strong>of</strong> B given A.<br />

Prob (B|A) Prob (A)<br />

Prob (A|B) =<br />

Prob (B)<br />

Suppose one knows the probability <strong>of</strong> A and wants to know how this probability changes<br />

if we know that B has occurred. Prob(A) is called the prior probability. The conditional<br />

probability Prob(A|B) is called the posterior probability because it is the probability <strong>of</strong><br />

A after we know that B has occurred.<br />

The example below illustrates that if a situation is rare, a highly accurate test will<br />

<strong>of</strong>ten give the wrong answer.<br />

Example: Let A be the event that a product is defective and let B be the event that a<br />

test says a product is defective. Let Prob(B|A) be the probability that the test says a<br />

product is defective assuming the product is defective and let Prob ( B|Ā) be the probability<br />

that the test says a product is defective if it is not actually defective.<br />

What is the probability Prob(A|B) that the product is defective if the test say it is<br />

defective? Suppose Prob(A) = 0.001, Prob(B|A) = 0.99, and Prob ( B|Ā) = 0.02. Then<br />

Prob (B) = Prob (B|A) Prob (A) + Prob ( B|Ā) Prob ( Ā )<br />

= 0.99 × 0.001 + 0.02 × 0.999<br />

= 0.02087<br />

395

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!