/Segment1

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search

Segment 1 (16 January 2013)

Jan. 16th Wed, Segment 1

Problems:

1. show <math>P(ABC)=P(B)P(C | B) P(A | BC)</math>

right side:<math>P(B)P(C | B) P(A | BC) = P(BC)P(A|BC)</math> <math>=P(ABC)</math>

2. What is the probability that the sum of two dice is odd with neither being a 4?

P(neither being 4 & sum of two dice is odd) =P(neither being 4 | sum of two dice is odd)* P(sum of two dice is odd) =12/18 * 18/36 =1/3

Think about

3. For the trout/minnow problem, what if you want to know the probability that the Nth fish caught is a trout, for N=1,2,3,... What is an efficient way to set up this calculation? (Hint: If you ever learned the word "Markov", this might be a good time to remember it!)

if N=1, P=2/5;

if N=2, P=P(1st is trout & 2nd is trout) + P(1st is minnow & 2nd is trout)=2/5*1/4 +3/5*2/5=0.34;

if N>2, P=P(Nth is trout & didn't have a trout before) + P(Nth is trout & had a trout before)

P(Nth is trout & didn't have a trout before) = (3/5)^(N-1) * (2/5)

P(Nth is trout & had a trout before) =P (Nth is a trout when there's one left) * [ P(1st trial got trout) +P( 2nd trial got trout) + ... +P (N-1 th trial got trout) ]

<math>\begin{align}

= (1/4) * [ (2/5) * (3/4)^{N-2} + (3/5) * (2/5) * (3/4)^{N-3} + (3/5)^2 * (2/5) * (3/4)^{N-4} + ... + (3/5)^{N-2}* (2/5) ] \\

=(1/4) * \sum_{i=0}^{N-2} (3/5)^i * (2/5) * (3/4)^{N-2-i} \\

\end{align}</math>

So, <math> P = (3/5)^{N-1} * (2/5) + (1/4) * \sum_{i=0}^{N-2} (3/5)^i * (2/5) * (3/4)^{N-2-i} </math>

in class problem

1. you are an oracle that, when asked, says "yes" with probability P and "no" with probability 1 − P. How do you do this using only a fair, two‐sided coin?


2. In the programming language of your choice, how would you simulate flips of a fair, two‐ sided coin? Do it. Simulate 106 flips. How many heads do you get?

Coin.png

In the programming language of your choice, how would you simulate draws from two weird 7‐sided dice whose faces (showing 1 through 7 spots) have probabilities proportional to: <math> 1:e: \pi :4:5:6:e^ \pi </math> respectively ? – Do it. Simulate 106 throws of the dice. How many times is the sum of the two dice equal to 8? – What should it be (in expectation) analytically?

Weirddice.png

To calculated the expected probability, I summed across the probability of all possible combinations:

Weirddice2.png

I got 62606 times with the sum being 8, over the 10**6 tossing.

So, the observed probability is 0.62606.