# Segment 1

## Calculation Problems

1. Prove that $P(ABC) = P(B)P(C|B)P(A|BC)$

In general by Conditional Probability, $P(B|A) = \frac{P(AB)}{P(A)}$

\begin{align}P(B)P(C|B)P(A|BC) &= P(B)\text{ }\frac{P(BC)}{P(B)}\text{ }\frac{P(ABC)}{P(BC)}\\ &= P(ABC)\end{align}


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

There are totally 36 possibilities when two dice are thrown. 18 of those are even sums and 18 are odd sums. Among the odd sums, there are 6 which have a 4 in one of the dice.

\begin{align}P(\text{Odd sum with no 4s}) &= \frac{36-18-6}{36} \\ &= \frac{12}{36}\\ &= \frac{1}{3}\end{align}

## Food for Thought Problems

1. First-order logic, from my understanding, seems like it can be used as a calculus of inference. No, this is very different form the probability axioms. One of Cox's axions is equivalent to that "if more there is belief on the negation less there is belief on the proposition". In First-Order Logic, if a proposition p is true then the negation of p is also true

2. The Oracle Thought problem was part of the Class Activity.

3. ??? "Markov's Chain" ???

## Class Activity

1. First we can convert the probability that the oracle says “yes” $P$ to a binary fraction. For example $1/3$ would in binary be $0.01010101010...$. The oracle would flip a coin and make a string of 0s and 1s, where heads could corresponds to 1 and tails to 0. This string is compared to only the binary fraction part of $P$. Once the string is lesser than $P$, the oracle would say yes and he would say no otherwise.

Python code for the solution:

import math
import random
yes = 0
no = 0
#Comment below
#p = float(1.0/3)
for i in range(1000):
done = 0
noflips = 0
p = float(1.0/3)
while not done:
p , b = math.modf(p*2)
noflips += 1
r = random.randint(0,1)
if r != b:
done = 1
print noflips
if r > b:
no += 1
else:
yes += 1
print yes
print no


Comment When I ran this program without reseting p after every trial, python's float has only a fixed number of fraction part. This makes p = 0.0 after around 30 trials which gives a higher number of no's than yes's.

2. Using python’s random number generator.

import random
for i in range(1000000):
print tails

Output:
Tails = 500440


3. Solution written in python:

import random
import numpy as np
import math
s = 1+math.e+math.pi+4+5+6+math.pow(math.e,math.pi)
val = [1/s,math.e/s,math.pi/s,4/s,5/s,6/s, math.pow(math.e,math.pi)/s]
count = 0
for i in range(10**6):
a = np.random.multinomial(1, val, 2)
dice = a[0][0] + 2*a[0][1] + 3*a[0][2] + 4*a[0][3] + 5*a[0][4] + 6*a[0][5] + 7*a[0][6]
dice += a[1][0] + 2*a[1][1] + 3*a[1][2] + 4*a[1][3] + 5*a[1][4] + 6*a[1][5] + 7*a[1][6]
if dice > 8:
count += 1
print count