Skip to content

Commit 7ab0b30

Browse files
fixed solutions listed in internal (12/24/2024)
1 parent 851d8a8 commit 7ab0b30

File tree

15 files changed

+525
-208
lines changed

15 files changed

+525
-208
lines changed
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
So um, this algorithm pretty much counts the number of attempts we make until we get $HHH$ or $TTT$
1+
Since we have an endless algorithm (i.e the algorithm will run forever until it finds a solution), we can model this problem using a geometric distribution.
22

3-
We have a $ \frac{1}{8} $ chance of flipping an $HHH$
3+
By the geometric distribution, the expected value of the number of attempts until we get a success is $\frac{1}{p}$, where $p$ is the probability of terminating the algorithm at each step.
44

5-
We have a $ \frac{1}{8} $ chance of flipping an $TTT$
5+
In this case, the probability of terminating the algorithm is either getting three heads in a row or getting three tails in a row. The probability of getting three heads in a row is $\frac{1}{2^3} = \frac{1}{8}$, and the probability of getting three tails in a row is also $\frac{1}{8}$. Therefore, the probability of terminating the algorithm at each step is $\frac{1}{8} + \frac{1}{8} = \frac{1}{4}$.
66

7-
This gives us a $ \frac{1}{4} $ chance of flipping either $HHH$ or $TTT$
8-
9-
By the geometric distribution, the expected value of the number of attempts until we get a success is $ \frac{1}{p} $
10-
11-
Therefore, the expected value of $X$ is $ \frac{1}{ \frac{1}{4}} = 4 $
7+
Now, we can calculate the expected value using the formula for expected value for geometric distribution: $E(X) = \frac{1}{p} = \frac{1}{\frac{1}{4}} = 4$.
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
Let's write out the possibilities I guess
1+
# Recursive Breakdown
22

3-
<ul>
4-
<li> $ b, S_{n-1} $
5-
<li> $ c, S_{n-1} $
6-
<li> $ a, 3^{n-1} $ because we could have our first $a$ here, and the rest of the string can be any of the 3 characters
7-
</ul>
3+
Consider two cases based on the **first character** of the string:
84

9-
$ S_n = 2 \cdot S\_{n-1} + 3^{n-1} $
5+
1. **If the first character is 'a':**
6+
7+
The remaining $n - 1$ characters can be any string of length $n - 1$ using **a, b, c**. The number of such strings is $3^{n-1}$.
8+
9+
2. **If the first character is 'b' or 'c':**
10+
11+
The string must still contain at least one 'a' in the remaining $n - 1$ characters. This is equivalent to counting valid strings of length $n - 1$ containing at least one 'a', which is $S_{n-1}$. Since the first character can be either **'b'** or **'c'** (2 choices), the contribution is: $2 \cdot S_{n-1}$
12+
13+
Adding both contributions: $S_n = 2 \cdot S_{n-1} + 3^{n-1}$
Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
1-
Let's explain why some are wrong and one is right
2-
3-
<ul>
4-
<li> ${\sum_{k=1}^{100}} k \cdot \frac{k^{2}}{100^{2}}$ <br/>
5-
This equation says, \enquote{The probability that k is the max value and each value has 1 to k values to be} <br/>
6-
This doesn't work because it's saying that the max value is k if $a$ is 1 and $b$ is 1
7-
<li> ${\sum_{k=1}^{100}} k \cdot \frac{k(k-1)}{100^{2}}$ <br/>
8-
This equation says, \enquote{a can be any value from 1 to k and b can be any value from 1 to k-1} <br/>
9-
This doesn't work because it's saying that the max value is k if $a$ is $k-1$ and $b$ is $k-2$
10-
<li> ${\sum_{k=1}^{100}} k \cdot \frac{2k}{100^{2}}$ <br/>
11-
This equation says, \enquote{a can be any value from 1 to k and b can be any value from 1 to k} <br/>
12-
This doesn't work because it's saying that the max value is k if $a$ is 1 and $b$ is 1
13-
<li> ${\sum_{k=1}^{100}} k \cdot bigg( \frac{1+2(k-1)}{100^{2}}bigg)$ <br/>
14-
This one actually has multiple possibilities <br/>
15-
<ul>
16-
<li> $a = k$ and $b = k$: 1 possibility
17-
<li> $a = k$ and $b$ is any value less than k: $k(k-1)$ possibilities
18-
<li> $a$ is any value less than k and $b = k$: $(k-1)k$ possibilities
19-
</ul>
20-
Summing them up, we get $1 + 2 \cdot k(k-1) $
21-
Each of the tree posibilities above makes sure that the max value is k
22-
</ul>
1+
## Goal of Problem
2+
3+
We want to calculate the **expected value** of the random variable: $X = \max(a, b)$ where:
4+
5+
- $ a $ and $ b $ are chosen independently and uniformly from the set $ \{1, 2, \ldots, 100\} $.
6+
7+
---
8+
9+
## **Key Observation**
10+
11+
The maximum of two independent uniformly random variables, $ a $ and $ b $, takes the value $ k $ if:
12+
13+
- At least one of the two numbers is equal to $ k $.
14+
- The other number is **less than or equal to $ k $**.
15+
16+
### **Probability that $ X = k $**
17+
18+
For a maximum of $ k $ to occur:
19+
20+
1. At least one of $ a $ or $ b $ must be equal to $ k $.
21+
2. The other value must be $ \leq k $.
22+
23+
The total number of outcomes for $ (a, b) $ is: $100^2$ since $ a $ and $ b $ are chosen from $ \{1, 2, \ldots, 100\}$.
24+
25+
The favorable outcomes for $ X = k $ are:
26+
27+
- $ a = k $ and $ b \leq k $: $ k $ outcomes.
28+
- $ b = k $ and $ a \leq k $: $ k $ outcomes.
29+
- $ a = b = k $ is counted twice, so subtract 1.
30+
31+
Total favorable outcomes: $2k - 1$
32+
33+
This means the probability that $ X = k $ is: $P(X = k) = \frac{|X = k|}{|S|} = \frac{2k - 1}{100^2}$.
34+
35+
---
36+
37+
## **Substituting Expected Value Formula**
38+
39+
By the definition of expected value: $E(X) = \sum\_{k=1}^{100} k \cdot P(X = k)$
40+
41+
Substituting the probability: $E(X) = \sum\_{k=1}^{100} k \cdot \frac{2k - 1}{100^2}$
42+
43+
We can rewrite $2k-1$ as $1 + 2(k-1)$. They result in the same sum, so we get: $E(X) = \sum\_{k=1}^{100} k \cdot \left(\frac{1 + 2(k-1)}{100^2}\right)$
Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,65 @@
1-
Before drawing a tree, let's think for a second
1+
## **Counterexample to Show $ X $ and $ Y $ Are Not Independent**
22

3-
We just need to prove whether the following is true for some value $x$ and $y$: $ Pr(X=i \cap Y=j) = Pr(X=i) \cdot Pr(Y=j) $
3+
We want to demonstrate mathematically that the random variables:
44

5-
Let's do it for X=2 and Y=2
5+
- $ X = i + j $ (sum of two six-sided dice rolls)
6+
- $ Y = i - j $ (difference between two six-sided dice rolls)
67

7-
$ |S| = 36 $
8+
are **not independent** by showing an example where the independence condition $P(X = x \land Y = y) = P(X = x) \cdot P(Y = y)$ **fails** for certain values of $ x $ and $ y $.
89

9-
$X=2$ for the pair $ (1,1) $
10+
---
1011

11-
$ Pr(X=2) = \frac{1}{36} $
12+
## **Choose Specific Values**
1213

13-
$Y=5$ for the pairs $ (6,1), (1,6) $
14+
Let:
1415

15-
$ Pr(Y=5) = \frac{2}{36} $
16+
- $ X = 4 $ (sum of the two dice is 4)
17+
- $ Y = 2 $ (difference between the two dice is 2)
1618

17-
Now, let's find the case of $ X=2 \cap Y=5 $
19+
We will compute:
1820

19-
When we look at overlapping pairs in $X=2$ and $Y=5$, we see that there is no intersection
21+
1. $ P(X = 4 \land Y = 2) $
22+
2. $ P(X = 4) $
23+
3. $ P(Y = 2) $
24+
4. Check if the independence formula holds.
2025

21-
This means that $ Pr(X=2 \cap Y=5) = 0 $
26+
---
2227

23-
$ Pr(X=2 \cap Y=5) = Pr(X=2) \cdot Pr(Y=5) $
28+
## **Joint Probability $ P(X = 4 \land Y = 2) $**
2429

25-
Since the equation is false, X and Y are not independent.
30+
For $ X = 4 $ and $ Y = 2 $:
31+
32+
- The sum $ i + j = 4 $
33+
- The difference $ i - j = 2 $
34+
35+
Possible pairs $(i, j)$ that satisfy both conditions: $ (3,1) $
36+
37+
There is **1 valid outcome** out of $ 36 $ total outcomes, so $P(X = 4 \land Y = 2) = \frac{1}{36}$
38+
39+
---
40+
41+
## **Marginal Probability $ P(X = 4) $**
42+
43+
Possible pairs where the sum is 4: $ (1,3), (2,2), (3,1) $
44+
45+
There are **3 valid outcomes** out of $36$ total outcomes, so $P(X = 4) = \frac{3}{36} = \frac{1}{12}$
46+
47+
---
48+
49+
## **Marginal Probability $ P(Y = 2) $**
50+
51+
Possible pairs where the difference is 2: $ (3,1), (4,2), (5,3), (6,4) $
52+
53+
There are **4 outcomes** out of $36$ total outcomes, so $P(Y = 2) = \frac{4}{36} = \frac{1}{9}$
54+
55+
## **Check Independence Condition**
56+
57+
If $ X $ and $ Y $ were independent, we would expect: $P(X = 4 \land Y = 2) = P(X = 4) \cdot P(Y = 2)$
58+
59+
Substituting the probabilities: $\frac{1}{36} \stackrel{?}{=} \frac{1}{12} \cdot \frac{1}{9}$
60+
61+
Simplify the right-hand side: $\frac{1}{12} \cdot \frac{1}{9} = \frac{1}{108}$
62+
63+
Comparing the two probabilities: $\frac{1}{36} \neq \frac{1}{108}$
64+
65+
Clearly, the probabilities **do not match**, which means that the random variables $ X $ and $ Y $ are **not independent**.
Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
1-
Okay, there are two ways to go about this
1+
## **Answer by Observation**
22

3-
<ul>
4-
<li> The first is to realize that the chance the coin comes up a certain face an odd or even number of times is straight up $ \frac{1}{2} $ <br/>
5-
Screw drawing out the whole 5-level deep recursive tree. We can just draw out a 3-level deep tree <br/>
6-
<img src="/images/comp2804/2018-fall-final/11/image.png"/> <br/>
7-
If you notice, our first flip gets us a head or a tail, which is a 50/50 chance. <br/>
8-
The first flip doubles the possibilities <br/>
9-
If after flipping a heads we flip a heads again, this creates an even number of tails BUT the probability is kept the same by the fact that another possibility is HT <br/>
10-
If after flipping a tails we flip a tails, it's even BUT the counter is that we could land a TH, which brings the probability back to 50/50 <br/>
11-
Ever time we flip the coin to get an odd number of heads, we could just as easily have gotten an even number of tails <br/>
12-
Some of the exam questions are like this, and it's not really worth the time to brute force calculate <br/>
13-
It's as intuitive as it is unintuitive
14-
<li> Second, we can draw out a tree and realize that the probability of getting an odd number of heads is the same as getting an even number of heads
15-
<li> Third, let's just waste brainpower to solve this <br/>
16-
<ul>
17-
<li> Let S be all possible outcomes of the coin flips: $ |S| = 2^5 = 32 $
18-
<li> Let A represent the event that the coin comes up heads once <br/>
19-
We choose 1 position out of the 5 for the head: $ \binom{5}{1} $ <br/>
20-
The remaining 4 positions are for the tails: 1 <br/>
21-
$ |A| = \binom{5}{1} $
22-
<li> Let B represent the event that the coin comes up heads 3 times <br/>
23-
We choose 3 positions out of the 5 for the heads: $ \binom{5}{3} $ <br/>
24-
The remaining 2 positions are for the tails: 1 <br/>
25-
$ |B| = \binom{5}{3} $
26-
<li> Let C represent the event that the coin comes up heads 5 times <br/>
27-
We choose 5 positions out of the 5 for the heads: $ \binom{5}{5} $ <br/>
28-
The remaining 0 positions are for the tails: 1 <br/>
29-
$ |C| = \binom{5}{5} $
30-
</ul>
31-
$ Pr(\text{odd number of heads}) = Pr(A) + Pr(B) + Pr(C) $<br/>
32-
$ Pr(\text{odd number of heads}) = \frac{ \binom{5}{1} + \binom{5}{3} + \binom{5}{5} }{32} $ <br/>
33-
$ Pr(\text{odd number of heads}) = \frac{5 + 10 + 1}{32} $ <br/>
34-
$ Pr(\text{odd number of heads}) = \frac{16}{32} $ <br/>
35-
$ Pr(\text{odd number of heads}) = \frac{1}{2} $
36-
</ul>
3+
Each flip of a fair coin has two equally likely outcomes:
4+
5+
- $ H $ (Heads)
6+
- $ T $ (Tails)
7+
8+
When flipping 5 coins:
9+
10+
- The total number of possible outcomes is: $2^5 = 32$
11+
- Half of these outcomes will have an **odd number of heads**, and the other half will have an **even number of heads**.
12+
13+
### **Why Are They Evenly Split?**
14+
15+
- For every outcome with an **odd number of heads**, there is a corresponding outcome with an **even number of heads** by flipping one coin from heads to tails (or vice versa).
16+
- This creates a **1-to-1 correspondence** between odd and even outcomes.
17+
18+
Thus, the probability of an **odd number of heads** is: $P(\text{Odd number of heads}) = \frac{1}{2}$
Lines changed: 108 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,111 @@
1-
<ul>
2-
<li> Let's determine $ B $ <br/>
3-
What we care about is when we get an $a$ so let's map that out with a table <br/>
4-
<img src="/images/comp2804/2018-fall-final/13/image.png"/> <br/>
5-
$ |B| = 11 $ <br/>
6-
$ Pr(B) = \frac{11}{36} $
7-
<li> Let's determine $ A \cap B $ <br/>
8-
We only care about the cases when both rolls result in the same letter AND at least one of the rolls result in the letter $a$ <br/>
9-
![alt text](image-1.png) <br/>
10-
$ |A \cap B| = 1 $ <br/>
11-
$ Pr(A \cap B) = \frac{1}{36} $
12-
</ul>
1+
In this case, our dice has special properties compared to a normal 6-sided dice. <br />
2+
We can define the dice as having the following results: {a, b, b, c, c, c} <br />
3+
Now, all we have to do is determine $Pr(A \cap B)$ and $Pr(B)$ to determine $Pr(A|B)$ using the independence formula. <br />
134

14-
$ Pr(A|B) = \frac{ Pr(A \cap B) }{ Pr(B) } $
5+
$Pr(B)$ represents the probability of at least one of the rolls resulting in the letter $a$. To make this easier to visualize, we can draw out a table of all possible outcomes between the two dice rolls. <br />
6+
$|S|$ = the sample space of all possible rolls = $6 \times 6 = 36$ <br />
157

16-
$ Pr(A|B) = \frac{ \frac{1}{36} }{ \frac{11}{36} } $
8+
<table style="
9+
border-collapse: collapse;
10+
margin: 0 auto;
11+
table-layout: fixed;
12+
width: 600px;">
13+
<caption style="
14+
font-size: 1.25rem;
15+
font-weight: bold;
16+
margin-bottom: 10px;">
17+
All Possible Rolls for Two Custom 6-Sided Dice
18+
</caption>
19+
<thead>
20+
<tr>
21+
<th style="
22+
border: 1px solid #ccc;
23+
padding: 10px;
24+
text-align: center;
25+
background-color: #f2f2f2;"></th>
26+
<th style="
27+
border: 1px solid #ccc;
28+
padding: 10px;
29+
text-align: center;
30+
background-color: #f2f2f2;">Die 2: a</th>
31+
<th style="
32+
border: 1px solid #ccc;
33+
padding: 10px;
34+
text-align: center;
35+
background-color: #f2f2f2;">Die 2: b</th>
36+
<th style="
37+
border: 1px solid #ccc;
38+
padding: 10px;
39+
text-align: center;
40+
background-color: #f2f2f2;">Die 2: b</th>
41+
<th style="
42+
border: 1px solid #ccc;
43+
padding: 10px;
44+
text-align: center;
45+
background-color: #f2f2f2;">Die 2: c</th>
46+
<th style="
47+
border: 1px solid #ccc;
48+
padding: 10px;
49+
text-align: center;
50+
background-color: #f2f2f2;">Die 2: c</th>
51+
<th style="
52+
border: 1px solid #ccc;
53+
padding: 10px;
54+
text-align: center;
55+
background-color: #f2f2f2;">Die 2: c</th>
56+
</tr>
57+
</thead>
58+
<tbody>
59+
<tr>
60+
<th style="
61+
border: 1px solid #ccc;
62+
padding: 10px;
63+
text-align: center;
64+
font-weight: bold;
65+
background-color: #f2f2f2;">Die 1: a</th>
66+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(a,a)</td>
67+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(a,b)</td>
68+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(a,b)</td>
69+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(a,c)</td>
70+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(a,c)</td>
71+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(a,c)</td>
72+
</tr>
73+
<tr>
74+
<th style="
75+
border: 1px solid #ccc;
76+
padding: 10px;
77+
text-align: center;
78+
font-weight: bold;
79+
background-color: #f2f2f2;">Die 1: b</th>
80+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(b,a)</td>
81+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(b,b)</td>
82+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(b,b)</td>
83+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(b,c)</td>
84+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(b,c)</td>
85+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(b,c)</td>
86+
</tr>
87+
<tr>
88+
<th style="
89+
border: 1px solid #ccc;
90+
padding: 10px;
91+
text-align: center;
92+
font-weight: bold;
93+
background-color: #f2f2f2;">Die 1: c</th>
94+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(c,a)</td>
95+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(c,b)</td>
96+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(c,b)</td>
97+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(c,c)</td>
98+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(c,c)</td>
99+
<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">(c,c)</td>
100+
</tr>
101+
</tbody>
102+
</table>
17103

18-
$ Pr(A|B) = \frac{1}{11} $
104+
As we can see from the table, there are 11 possible outcomes that have at least 1 $a$ in them. Therefore, $Pr(B) = \frac{|B|}{|S|} = \frac{11}{36}$. <br />
105+
106+
For $Pr(A \cap B)$, we only care about the cases when both rolls result in the same letter AND at least one of the rolls result in the letter $a$. <br />
107+
From the table, we can see that there is only 1 possible outcome that satisfies both conditions, which is the case where both dice roll an $a$. Therefore, $Pr(A \cap B) = \frac{|A \cap B|}{|S|} = \frac{1}{36}$. <br />
108+
109+
Given this, we can now calculate $Pr(A|B)$ using the independence formula: <br />
110+
111+
$ Pr(A|B) = \frac{ Pr(A \cap B) }{ Pr(B) } = \frac{ \frac{1}{36} }{ \frac{11}{36} } = \frac{1}{11} $ <br />

0 commit comments

Comments
 (0)