![Page 1: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/1.jpg)
Convolution and ConditionalChris Piech
CS109, Stanford University
![Page 2: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/2.jpg)
Scores for a standardized test that students in Poland are required to pass before moving on in school
See if you can guess the minimum score to pass the test.
2http://freakonomics.com/2011/07/07/another-case-of-teacher-cheating-or-is-it-just-altruism/comment-page-2/
Altruism?
![Page 3: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/3.jpg)
CO2 Today: 407 parts per million (ppm)
CO2 Pre-Industrial: 275 parts per million (ppm)
![Page 4: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/4.jpg)
Climate Sensitivity
![Page 5: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/5.jpg)
0.0
0.1
0.1
0.2
0.2
0.3
0.3
0 1 2 3 4 5 6 7
Prob
abili
ty
8 9 10 11
Climate Sensitivity
12
Equilibrium Climate Sensitivity (degrees Celsius)
![Page 6: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/6.jpg)
Four Prototypical Trajectories
Algorithmic Practice
![Page 7: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/7.jpg)
Choosing a Random Subset
Original Set (size n) Subset (size k)
![Page 8: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/8.jpg)
• From set of n elements, choose a subset of size ksuch that all possibilities are equally likely§ Only have random(), which simulates X ~ Uni(0, 1)
• Brute force:§ Generate (an ordering of) all subsets of size k§ Randomly pick one (divide (0, 1) into intervals)§ Expensive with regard to time and space§ Bad times!
⎟⎟⎠
⎞⎜⎜⎝
⎛
kn
⎟⎟⎠
⎞⎜⎜⎝
⎛
kn
Choosing a Random Subset
![Page 9: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/9.jpg)
• Good times:int indicator(double p) {
if (random() < p) return 1; else return 0;}
subset rSubset(k, set of size n) {subset_size = 0;I[1] = indicator((double)k/n);for(i = 1; i < n; i++) {
subset_size += I[i];I[i+1] = indicator((k – subset_size)/(n – i));
}return (subset containing element[i] iff I[i] == 1);
}
niiIIiIPnkIP in
jIki
j <<==+== −
∑−= 1 ])[],...,1[|1]1[( )1]1[(
][1 whereand
(Happily) Choosing a Random Subset
![Page 10: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/10.jpg)
Choosing a Random Subset
Original Set (size n) Subset (size k)
![Page 11: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/11.jpg)
• Proof (Induction on (k + n)): (i.e., why this algorithm works)§ Base Case: k = 1, n = 1, Set S = {a}, rSubset returns {a} with p=
§ Inductive Hypoth. (IH): for k + x ≤ c, Given set S, |S| = x and k ≤ x,rSubset returns any subset S’ of S, where |S’| = k, with p =
§ Inductive Case 1: (where k + n ≤ c + 1) |S| = n (= x + 1), I[1] = 1o Elem 1 in subset, choose k – 1 elems from remaining n – 1o By IH: rSubset returns subset S’ of size k – 1 with p =
o P(I[1] = 1, subset S’) =
§ Inductive Case 2: (where k + n ≤ c + 1) |S| = n (= x + 1), I[1] = 0o Elem 1 not in subset, choose k elems from remaining n – 1
o By IH: rSubset returns subset S’ of size k with p =
o P(I[1] = 0, subset S’) =
⎟⎟⎠
⎞⎜⎜⎝
⎛
kx
1
⎟⎟⎠
⎞⎜⎜⎝
⎛
−
−
11
1kn
⎟⎟⎠
⎞⎜⎜⎝
⎛=⎟⎟
⎠
⎞⎜⎜⎝
⎛
−
−⋅
kn
kn
nk 1
11
1
⎟⎟⎠
⎞⎜⎜⎝
⎛ −
kn 1
1
⎟⎟⎠
⎞⎜⎜⎝
⎛=⎟⎟
⎠
⎞⎜⎜⎝
⎛ −⋅⎟⎠
⎞⎜⎝
⎛ −=⎟⎟⎠
⎞⎜⎜⎝
⎛ −⋅⎟⎠
⎞⎜⎝
⎛ −kn
kn
nkn
kn
nk 1
11
111
⎟⎟⎠
⎞⎜⎜⎝
⎛
11
1
Random Subsets the Happy Way
![Page 12: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/12.jpg)
Induction Cases
Original Set (size n) Subset (size k)
![Page 13: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/13.jpg)
Case 1
Original Set (size n) Subset (size k)
![Page 14: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/14.jpg)
Case 1
Original Set (size n-1) Subset (size k-1)
By induction we know that all subsamples of size k-1 from n-1 items are equally likely
⎟⎟⎠
⎞⎜⎜⎝
⎛=⎟⎟
⎠
⎞⎜⎜⎝
⎛
−
−⋅
kn
kn
nk 1
11
1P(subset) =
![Page 15: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/15.jpg)
Choosing a Random Subset
Original Set (size n) Subset (size k)
![Page 16: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/16.jpg)
Case 2
Original Set (size n-1) Subset (size k)
By induction we know that all subsamples of size k from n-1 are equally likely
P(subset) = ⎟⎟⎠
⎞⎜⎜⎝
⎛=⎟⎟
⎠
⎞⎜⎜⎝
⎛ −⋅⎟⎠
⎞⎜⎝
⎛ −=⎟⎟⎠
⎞⎜⎜⎝
⎛ −⋅⎟⎠
⎞⎜⎝
⎛ −kn
kn
nkn
kn
nk 1
11
111
![Page 17: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/17.jpg)
Four Prototypical Trajectories
All combinations are in either case. Each combination in the cases are
equally likely
![Page 18: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/18.jpg)
The Story so Far
Joint Random Variables (in discrete and in continuous world)
Expectation
AddingConditionals
Independence
![Page 19: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/19.jpg)
Four Prototypical Trajectories
Conditionals with multiple variables
![Page 20: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/20.jpg)
• Recall that for events E and F:
0)( )()()|( >= FP
FPEFPFEP where
Discrete Conditional Distribution
FE
![Page 21: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/21.jpg)
• Recall that for events E and F:
• Now, have X and Y as discrete random variables§ Conditional PMF of X given Y (where pY(y) > 0):
§ Conditional CDF of X given Y (where pY(y) > 0):
0)( )()()|( >= FP
FPEFPFEP where
)(),(
)(),()|()|( ,
| ypyxp
yYPyYxXPyYxXPyxP
Y
YXYX =
=
======
)(),()|()|(| yYPyYaXPyYaXPyaF YX =
=≤==≤=
∑∑≤
≤ ==ax
YXY
ax YX yxpyp
yxp)|(
)(),(
|,
Discrete Conditional Distributions
![Page 22: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/22.jpg)
Conditional Probability?
![Page 23: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/23.jpg)
Relationship Status
![Page 24: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/24.jpg)
• Consider person buying 2 computers (over time)§ X = 1st computer bought is a PC (1 if it is, 0 if it is not)§ Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)§ Joint probability mass function (PMF):§ What is P(Y = 0 | X = 0)?
§ What is P(Y = 1 | X = 0)?
§ What is P(X = 0 | Y = 1)?
XY 0 1 pY(y)
0 0.2 0.3 0.5
1 0.1 0.4 0.5
pX(x) 0.3 0.7 1.031
3.01.0
)0()1,0(
)0|1( , =====X
YX
pp
XYP
32
3.02.0
)0()0,0(
)0|0( , =====X
YX
pp
XYP
51
5.01.0
)1()1,0(
)1|0( , =====Y
YX
pp
YXP
Operating System Loyalty
![Page 25: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/25.jpg)
P(Buy Book Y | Bought Book X)
And It Applies to Books Too
![Page 26: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/26.jpg)
• Let X and Y be continuous random variables§ Conditional PDF of X given Y (where fY(y) > 0):
§ Conditional CDF of X given Y (where fY(y) > 0):
§ Note: Even though P(Y = a) = 0, can condition on Y = ao Really considering:
)(),(
)|( ,| yf
yxfyxf
Y
YXYX =
dxyxfyYaXPyaFa
YXYX )|()|()|( || ∫∞−
==≤=
dyyfdydxyxf
dxyxfY
YXYX )(
),( )|( ,
| =
)|()(
),( dyyYydxxXxPdyyYyP
dyyYydxxXxP+≤≤+≤≤=
+≤≤
+≤≤+≤≤≈
∫+
−
≈=+≤≤−2/
2/
)()()( 22
ε
ε
εεεa
aY afdyyfaYaP
Continuous Conditional Distributions
![Page 27: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/27.jpg)
• X and Y are continuous RVs with PDF:
§ Compute conditional density:
⎩⎨⎧ <<−−
= otherwise 0 1 0 ere wh)2(),( 5
12 x,yyxxyxf
)|(| yxf YX
dxyxf
yxfyfyxf
yxf
YX
YX
Y
YXYX
),(
),()(
),()|( 1
0,
,,|
∫==
0
1232
1
0
1
0 23512
512 )2(
)2(
)2(
)2(
)2(
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−
−−=
−−
−−=
−−
−−=
∫∫yxx
x
yxx
dxyxx
yxx
dxyxx
yxx
yyxxyxx
y 34)2(6)2(
232 −
−−=
−−=
−
Let’s Do an Example
![Page 28: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/28.jpg)
Four Prototypical Trajectories
What happens when you add random variables?
![Page 29: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/29.jpg)
• Let X and Y be independent random variables§ X ~ Bin(n1, p) and Y ~ Bin(n2, p) § X + Y ~ Bin(n1 + n2, p)
• Intuition:§ X has n1 trials and Y has n2 trials
o Each trial has same “success” probability p
§ Define Z to be n1 + n2 trials, each with success prob. p§ Z ~ Bin(n1 + n2, p), and also Z = X + Y
• More generally: Xi ~ Bin(ni, p) for 1 ≤ i ≤ N
⎟⎠
⎞⎜⎝
⎛⎟⎠
⎞⎜⎝
⎛∑∑==
pnXN
ii
N
ii ,Bin~
11
Sum of Independent Binomials
![Page 30: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/30.jpg)
• Let X and Y be independent random variables§ X ~ Poi(λ1) and Y ~ Poi(λ2)
§ X + Y ~ Poi(λ1 + λ2)
• Proof: (just for reference)
§ Rewrite (X + Y = n) as (X = k, Y = n – k) where 0 ≤ k ≤ n
§ Noting Binomial theorem:
§ so, X + Y = n ~ Poi(λ1 + λ2)
∑∑==
−===−====+n
k
n
kknYPkXPknYkXPnYXP
00
)()(),()(
∑∑∑=
−+−
=
−+−
=
−−−
−=
−=
−=
n
k
knkn
k
knkn
k
knk
knkn
ne
knke
kne
ke
021
)(
0
21)(
0
21
)!(!!
!)!(!)!(!
212121 λλ
λλλλ λλλλλλ
( )nn
enYXP 21
)(
!)(
21
λλλλ
+==++−
∑=
−
−=+
n
k
knkn
knkn
02121 )!(!
!)( λλλλ
Sum of Independent Poissons
![Page 31: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/31.jpg)
• Let X and Y be independent Binomial RVs§ X ~ Bin(n1, p) and Y ~ Bin(n2, p) § X + Y ~ Bin(n1 + n2, p)§ More generally, let Xi ~ Bin(ni, p) for 1 ≤ i ≤ N, then
• Let X and Y be independent Poisson RVs§ X ~ Poi(λ1) and Y ~ Poi(λ2)§ X + Y ~ Poi(λ1 + λ2) § More generally, let Xi ~ Poi(λi) for 1 ≤ i ≤ N, then
⎟⎠
⎞⎜⎝
⎛⎟⎠
⎞⎜⎝
⎛∑∑==
pnXN
ii
N
ii ,Bin~
11
⎟⎠
⎞⎜⎝
⎛⎟⎠
⎞⎜⎝
⎛∑∑==
N
ii
N
iiX
11Poi~ λ
Reference: Sum of Independent RVs
![Page 32: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/32.jpg)
Four Prototypical Trajectories
If only it were always that simple
![Page 33: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/33.jpg)
We talked about sum of Binomial and Poisson…who’s missing from this party?
Uniform.
CON
Convolution of Probability Distributions
![Page 34: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/34.jpg)
Four Prototypical Trajectories
Summation: not just for the 1%
![Page 35: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/35.jpg)
• Let X and Y be independent random variables§ Cumulative Distribution Function (CDF) of X + Y:
§ FX+Y is called convolution of FX and FY
§ Probability Density Function (PDF) of X + Y, analogous:
§ In discrete case, replace with , and f(y) with p(y)
)()( aYXPaF YX ≤+=+
∫ ∫∫∫∞
−∞=
−
−∞=≤+
==y
ya
xYX
ayxYX dyyfdxxfdydxyfxf )( )( )()(
∫∞
−∞=
−=y
YX dyyfyaF )( )(
∫∞
−∞=
+ −=y
YXYX dyyfyafaf )( )()(
∫∞
−∞=y∑y
Dance, Dance Convolution
![Page 36: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/36.jpg)
• Let X and Y be independent random variables§ X ~ Uni(0, 1) and Y ~ Uni(0, 1) à f(x) = 1 for 0 ≤ x ≤ 1
Sum of Independent Uniforms
1
1f(x)
For both X and Y
![Page 37: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/37.jpg)
• Let X and Y be independent random variables§ X ~ Uni(0, 1) and Y ~ Uni(0, 1) à f(x) = 1 for 0 ≤ x ≤ 1
§ What is PDF of X + Y?
∫∫==
+ −=−=1
0
1
0
)( )( )()(y
Xy
YXYX dyyafdyyfyafaf
Sum of Independent Uniforms
fX+Y (0.5) =
Z y=?
y=?fX(0.5� y)dy
=
Z 0.5
0fX(0.5� y)dy
=
Z 0.5
01dy
= 0.5
When a = 0.5:
a21
1
)(af YX +
![Page 38: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/38.jpg)
• Let X and Y be independent random variables§ X ~ Uni(0, 1) and Y ~ Uni(0, 1) à f(x) = 1 for 0 ≤ x ≤ 1
§ What is PDF of X + Y?
∫∫==
+ −=−=1
0
1
0
)( )( )()(y
Xy
YXYX dyyafdyyfyafaf
Sum of Independent Uniforms
When a = 1.5:
a21
1
)(af YX +fX+Y (1.5) =
Z y=?
y=?fX(1.5� y)dy
=
Z 1
0.5fX(1.5� y)dy
=
Z 1
0.51dy
= 0.5
![Page 39: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/39.jpg)
• Let X and Y be independent random variables§ X ~ Uni(0, 1) and Y ~ Uni(0, 1) à f(x) = 1 for 0 ≤ x ≤ 1
§ What is PDF of X + Y?
∫∫==
+ −=−=1
0
1
0
)( )( )()(y
Xy
YXYX dyyafdyyfyafaf
Sum of Independent Uniforms
When a = 1:
a21
1
)(af YX +fX+Y (1) =
Z y=?
y=?fX(1� y)dy
=
Z 1
0fX(1� y)dy
=
Z 1
01dy
= 1
![Page 40: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/40.jpg)
• Let X and Y be independent random variables§ X ~ Uni(0, 1) and Y ~ Uni(0, 1) à f(x) = 1 for 0 ≤ x ≤ 1
§ What is PDF of X + Y?
§ When 0 ≤ a ≤ 1 and 0 ≤ y ≤ a, 0 ≤ a–y ≤ 1 à fX(a – y) = 1
§ When 1 ≤ a ≤ 2 and a–1 ≤ y ≤ 1, 0 ≤ a–y ≤ 1 à fX(a – y) = 1
§ Combining:
∫∫==
+ −=−=1
0
1
0
)( )( )()(y
Xy
YXYX dyyafdyyfyafaf
adyafa
yYX == ∫
=
+
0
)(
adyafay
YX −== ∫−=
+ 2 )(1
1
⎪⎩
⎪⎨
⎧
≤<−
≤≤
=+
otherwise 0 21 2 10
)(
aaaa
af YXa
21
1
)(af YX +
Sum of Independent Uniforms
![Page 41: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/41.jpg)
• Let X and Y be independent random variables§ X ~ N(µ1, σ12) and Y ~ N(µ2, σ22)
§ X + Y ~ N(µ1 + µ2, σ12 + σ22)
• Generally, have n independent random variables Xi ~ N(µi, σi
2) for i = 1, 2, ..., n:
⎟⎠
⎞⎜⎝
⎛⎟⎠
⎞⎜⎝
⎛∑∑∑===
n
ii
n
ii
n
ii NX
1
2
11 ,~ σµ
Sum of Independent Normals
![Page 42: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/42.jpg)
• Say you are working with the WHO to plan a response to a the initial conditions of a virus:§ Two exposed groups§ P1: 50 people, each independently infected with p = 0.1§ P2: 100 people, each independently infected with p = 0.4§ Question: Probability of more than 40 infections?
Virus Infections
Sanity check: Should we use the Binomial Sum-of-RVs shortcut?A. YES!B. NO!C. Other/none/more
![Page 43: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/43.jpg)
• Say you are working with the WHO to plan a response to a the initial conditions of a virus:§ Two exposed groups§ P1: 50 people, each independently infected with p = 0.1§ P2: 100 people, each independently infected with p = 0.4§ A = # infected in P1 A ~ Bin(50, 0.1) ≈ X ~ N(5, 4.5)§ B = # infected in P2 B ~ Bin(100, 0.4) ≈ Y ~ N(40, 24)§ What is P(≥ 40 people infected)?§ P(A + B ≥ 40) ≈ P(X + Y ≥ 39.5)§ X + Y = W ~ N(5 + 40 = 45, 4.5 + 24 = 28.5)
8485.0)03.1(15.28455.39
5.2845)5.39( ≈−Φ−=⎟
⎠
⎞⎜⎝
⎛ −>
−=≥
WPWP
Virus Infections
![Page 44: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/44.jpg)
Four Prototypical Trajectories
End sum of independent vars
![Page 45: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/45.jpg)
• Requests received at web server in a day§ X = # requests from humans/day X ~ Poi(λ1)§ Y = # requests from bots/day Y ~ Poi(λ2)§ X and Y are independent à X + Y ~ Poi(λ1 + λ2)§ What is P(X = k | X + Y = n)?
)()()(
)(),()|(
nYXPknYPkXP
nYXPknYkXPnYXkXP
=+
−===
=+
−====+=
n
knk
n
knk
knkn
en
kne
ke
)()!(!!
)(!
)!(! 21
21
21)(
2121
21
λλλλ
λλλλ
λλ
λλ
+⋅
−=
+⋅
−⋅=
−
+−
−−−
knk
kn −
⎟⎟⎠
⎞⎜⎜⎝
⎛
+⎟⎟⎠
⎞⎜⎜⎝
⎛
+⎟⎟⎠
⎞⎜⎜⎝
⎛=
21
2
21
1
λλλ
λλλ
Web Server Requests Redux
(X|X + Y = n) ⇠ Bin
✓n,
�1
�1 + �2
◆
![Page 46: Convolution and Conditional - Stanford University€¦ · § Conditional PMF of X given Y (where p Y(y) > 0): ... § Y = 2nd computer bought is a PC (1 if it is, 0 if it is not)](https://reader033.vdocuments.us/reader033/viewer/2022053100/60587c232d828f202a20724c/html5/thumbnails/46.jpg)
Ε[CS109]This is actual midpoint of course
(Just wanted you to know)
Course Mean