alexandria/documents/by-course/pstat-120a/hw5/main.typ
Youwen Wu 311d309bf9
Some checks are pending
Deploy Quartz site to GitHub Pages using Nix / build (push) Waiting to run
Deploy Quartz site to GitHub Pages using Nix / deploy (push) Blocked by required conditions
auto-update(nvim): 2025-02-25 13:46:09
2025-02-25 13:47:22 -08:00

272 lines
7.6 KiB
Text

#import "@youwen/zen:0.1.0": *
#import "@preview/cetz:0.3.2"
#show: zen.with(
title: "Homework 5",
author: "Youwen Wu",
date: "Winter 2025",
)
#show figure: it => {
pad(y: 10pt, it)
}
#set enum(spacing: 2em)
#let correction = content => {
set text(fill: red)
box(stroke: 1pt, inset: 5pt, content)
}
#let subproblems = content => {
set enum(numbering: "a)")
content
}
#rect[
Initial score: $34/36$
]
#rect[
#set text(fill: red)
Revised score: $36/36$
]
1.
Define:
- $S_1 ~ "Bin"(80, p) =$ successful for 55 people
- $S_2$ = successful for the 2 friends
- $S_3$ = successful for the other 53 patients
- $q := 1-p$
Then we are looking for $P(S_2 | S_1 = 55)$.
$
P(S_2 | S_1 = 55) = P(S_2 sect S_1 = 55) / P(S_1 = 55)
$
We see that $P(S_2 sect S_1 = 55) = P(S_2) P(S_1 = 55)$.
$
P(S_2) &= p^2 \
P(S_1=55) &= vec(80,55) p^55 q^25 \
P(S_1) &= vec(78,53) p^53 q^25
$
So
$
(p^2 vec(78,53) p^53 q^25) / (vec(80,55) p^55 q^25) \
=(vec(78,53)) / (vec(80,55)) \
approx 0.4699
$
2.
#subproblems[
1. We have to make sure it integrates to unity.
$
integral_(-infinity)^infinity c e^(-2t) dif t = integral_0^infinity c e^(-2t) dif t &= lr(-1/2 c e^(-2t) |)_(t->infinity) - (lr(-1/2 c e^(-2t) |)_(t=0)) \
&= 1 / 2 c = 1
$
So $c = 2$.
2. Looking for $P(T > 4)$. This is simply
$
1 - P(T <= 4) \
= 1 - integral_0^4 2e^(-2t) dif t \
approx 0.000335
$
3. Let $X ~ "Bin"(0.00035, 100)$ represent this experiment. We seek $P(X = 6)$.
$
P(X=6) = vec(100,6) 0.00035^6 dot (1-0.00035)^94 \
approx 0
$
4. Let $X ~ "Pois"(0.00035 dot 100 = 0.035)$ represent this experiment. We seek $P(X = 6)$.
$
P(X=6) = e^(-0.035) (0.035^6) / 6! approx 0
$
5.
Yes, $p < 0.02$ and $n >= 100$.
]
3. #subproblems[
1. Check the left and right limits at infinity: $F(-infinity) = 0$, $F(infinity) = 1$.
$F$ can never take a value greater than 1 or less than 0.
$dif/(dif x) F(x) = e^(-x)$ which is positive for $x >= 0$ so it is
monotonically increasing.
Therefore it is a valid CMF (i).
For (ii), we just differentiate.
$ f(x) = dif / (dif x) F(x) = e^(-x) $
2. Check the left and right limits at infinity: $F(-infinity) = 0$, $F(infinity) = 0$.
So immediately we see it is not valid.
]
4. #subproblems[
1. We are looking for $P(X <= x)$, the CDF. Immediately notice that the state
space of $X$ is $0 <= X <= 0.5$. When asking for $P(X <= x)$, we are essentially asking the probability that our uniform point lies in this red region:
#figure(
align(
center,
cetz.canvas({
import cetz.draw: *
rect((0, 0), (5, 5), fill: red)
rect((1, 1), (4, 4), fill: white)
}),
),
caption: "point lies in the inset border",
)
But it seems much easier to find if the point lies in the center region
instead, which is $P(X >= x)$. We want the probability that $X$ is _at least_
$x$ distance away from the sides, which is basically asking if it lies within
a smaller square inset by $x$ from the unit square.
#figure(
align(
center,
cetz.canvas({
import cetz.draw: *
rect((0, 0), (5, 5), fill: white)
rect((1, 1), (4, 4), fill: red)
}),
),
caption: "point lies in the center",
)
Intuitively, trying to add up the values of many individual points sounds a
lot like an area!
What is the area of this square? The inset is $x$, so its side lengths are $1
- 2x$, and the area is therefore $4x^2 - 4x$. Then $P(X >= x) = "area of red square"/"area of unit square"$, and the unit square has area 1, so $P(X >= x) = 4x^2-4x$.
Then the CDF, $P(X <= x)$ is just
$ 1- P(X >=x) = 4x - 4x^2 $
2. The PDF is just the derivative of the CDF so
$
dif / (dif x) 4x - 4x^2 = 4 - 8x
$
#correction[
$-2$ points. We forgot to ensure the CDF is actually valid.
We need to make sure that the limits at infinity are 0 and 1. So
$
F_x = cases(4x-4x^2"," &"when" 0 <= x < 0.5, 0"," &"when" x < 0, 1"," &"when" x >= 0.5)
$
Also we should check that $F_x$ is monotone increasing (true) and always
lies in $[0,1]$ (true).
This means that the PDF is
$
f_x = cases(4 - 8x"," &"when" 0 <= x < 0.5, 0"," &"otherwise")
$
]
]
5. If we assume that each typo occurs independently and with a very small fixed
rate $p$, and each page has the same amount of words (with $>= 100$ words per
page), then this can be characterized by a Poisson distribution. To find
$lambda$, simply recall that the expected value is the mean and equal to
$lambda$ for the Poisson. Then the number of typos on each page can be
characterized by a Poisson
distribution $X ~ "Pois"(6)$ and we seek $P(X >= 4)$.
$
P(X >= 4) = 1 - P(X < 4) = 1 - sum_(k=0)^3 e^(-6) (6^k) / k! approx 0.8488
$
6. #subproblems[
1. We need to check it integrates to unity.
$
integral_(-infinity)^infinity f_X (x) dif x = integral_0^infinity 3e^(-3x) dif x = 1
$
2. $
PP(-1 < X < 1) = integral_(-1)^1 3e^(-3x) dif x approx 0.9502
$
3. $
PP(X < 5) = integral_(-infinity)^5 f_X dif x approx 1
$
4. $
PP(2 < X < 4 | X < 5) = PP(2 < X < 4) / PP(X < 5) = (integral_2^4 f_X (x) dif x) / (integral_0^5 f_X (x) dif x) approx 0.002473
$
5.
$
F_X (x) = cases(1 - e^(-3x)"," &"when" x > 0, 0"," &"otherwise")
$
]
7. $
F_X (x) = integral_(-infinity)^x f_X (t) dif t \
1 - F_X (x) = integral_x^infinity f_X (t) dif t \
integral_0^infinity 1 - F_x (x) dif x = integral_0^infinity integral_0^t f_X (t) dif x dif t \
= integral_0^infinity t f_X (t) dif t
$
8. #subproblems[
1. #figure(
cetz.canvas({
import cetz.draw: *
set-style(stroke: 0.4pt)
grid((-3, -3), (3, 3), step: 1.5, stroke: gray + 0.2pt)
line((-3, 0), (3, 0))
line((0, -3), (0, 3))
rect((0, 0), (1.5, 1.5), fill: gray)
line((0, 0), (1.5, 0.75))
line((0, 0), (1.5, 1.5))
line((0, 0), (0.75, 1.5))
}),
)
Note that the slope of a line through the origin is determined entirely by
any point it passes through. Therefore given a line slope $s$, any point
$(x,y)$ on this line satisfies slope $s = y/x$. We are for $P(S < s)$, but
notice that every slope less than $s$ is also given by all of the points in
the unit square on the line it defines. This means that we can reframe our
question as asking to choose a point uniformly in the unit square, and
finding the probability that it is located in the region underneath the line!
The probability is given by the ratio of the area of all under the line
divided by the area of the square. But since the area of the square is 1,
it's simply just the area under the line.
When the slope is less than 1, this probability is just the area of the triangle
formed by the edges of the square and the line through the origin. When the
slope is greater than 1, it's equal to 1 minus the area of the triangle.
(when the slope is $1$ the area is always $1/2$).
So the CDF is
$
F_S (s) = P(S <= s) = cases(1/2 s"," &"when" 0 < s <= 1, 1 - 1/(2s)"," &"when" < 1 < infinity, 0"," &"otherwise")
$
2. The PDF is just the derivative
$
f_S (s) = cases(1/2 "," &"when" 0 < s <= 1, 1/(2s^2)"," &"when" < 1 < infinity, 0"," &"otherwise")
$
]