Professional Documents
Culture Documents
Lecture 2020-04-24
Solution
Clearly, 𝑋 ∼ Geo0.5 with support ℕ. Since
𝑃 (𝑋 > 𝑥) = 1 − 𝐹𝑋 (𝑥) ,
reflect the CDF plot about the x-axis to get a plot of
−𝐹𝑋 (𝑥) and shift that upward by one unit along the
y-axis.
1.0
0.8
0.6
0.4
0.2
0.0
1 2 3 4 5
1.0
0.8
0.6
0.4
0.2
0.0
1 2 3 4 5
The syntax-error problem
A seasoned programmer makes, on average, one syn-
tax error every third effective page. By effective page is
meant 30 effective lines of code excluding any blank or
comment-only lines. Specify the most adequate distri-
bution for each of the following.
1. The number of syntax errors in a randomly chosen
code of 900 effective lines
Solution
View each effective line as Bernoulli experiment and a
syntax error, on that line, as a success. For simplicity,
assume that the programmer can make only one syntax
error on any effective line. Alternatively, assume, that
the compiler only records the first syntax error on each
effective line. It is safe to assume that scanning the
effective lines results in a sequence of Bernoulli trials.
“one syntax error every third effective page” translates
to “one syntax error every 90th effective line”, which, in
turn, translates to a relative frequency of 1/90. We can
thus assume a probaility 1/90 of success.
Define RVs
𝑋 ↔ ‘The number of syntax errors in a randomly chosen code of 900 effective lines’
𝐾 ↔ ‘The number of lines scanned by a compiler to find the first error’
Clearly, 𝑋 ∼ Bin900,1/90 and 𝐾 ∼ Geo1/90 .
The playlist problem
An mp3 playlist contains 40 songs in English and 20 in
Urdu. The mp3 player provides a random play function
which allows the user to specify the number of songs to
play and choose one of the two options: with replace-
ment and without replacement.
Solution
View as success a step to the left made by the particle.
Then, the random walk of the particle can be seen as a
sequence of independent Bernoulli trials each having
success probability 𝑝.
Define RVs
𝑋 ↔ ‘The number of moves until the 𝑚th left move’
Clearly, 𝑋 ∼ NB𝑚,𝑝 , and the required probability is
𝑚+𝑛−𝑘−1 𝑚
𝑃 (𝑋 = 𝑚 + 𝑛 − 𝑘) = NB (𝑚 + 𝑛 − 𝑘; 𝑚, 𝑝) = 𝑝 (1 − 𝑝) 𝑘−𝑚
𝑚−1
for 𝑘 ∈ {1, 2, . . . , 𝑛}.
Data communication
Data transmission, as bytes, over a computer interface
is prone to errors. The error in each transmitted byte,
however, is detected with probability 𝑝. If six errors
occur in a ten byte long sequence, the error correction
scheme in place requests a retransmission as soon as
the sixth error is detected. What is the probability of a
retransmission request placed?
Solution
View the error detection as a success. The bytes trans-
mitted can be modeled as Bernoulli trials each with
probability 𝑝 of success. Define RV
𝑋 ↔ ‘The number of bytes transmitted until 6th error detection’
Clearly, 𝑋 ∼ NB6,𝑝 , and the requited probability is
10 10
Õ Õ 𝑘−1 6
𝑃 (𝑋 ∈ [6 · ·10]) = NB (𝑘; 6, 𝑝) = 𝑝 (1 − 𝑝) 𝑘−6
5
𝑘=6 𝑘=6
Solution
The RVs
𝑋𝑛 ↔ ‘The number of slices a person gets from the pizza with 𝑛 slices’
are distributed as 𝑋𝑛 ∼ Bin𝑛,1/10 because any particu-
lar slice from a particular pizza can go to each person
with the same probability 1/10. It is safe to assume in-
dependence among the three RVs. The probability that
a person will have a slice from each pizza is
𝑃 (𝑋9 = 1, 𝑋6 = 1, 𝑋4 = 1) = 𝑃 (𝑋9 = 1) 𝑃 (𝑋6 = 1) 𝑃 (𝑋3 = 1)
= Bin (1; 9, 1/10) Bin (1; 6, 1/10) Bin (1; 4, 1/10)
8 5 3
9 1 9 6 1 9 4 1 9
= × × ≈ 0.04
1 10 10 1 10 10 1 10 10
The probability that a person will have at least a slice
from each pizza is
𝑃 (𝑋9 ≥ 1, 𝑋6 ≥ 1, 𝑋4 ≥ 1) = 𝑃 (𝑋9 ≥ 1) 𝑃 (𝑋6 ≥ 1) 𝑃 (𝑋3 ≥ 1)
= [1 − 𝑃 (𝑋9 = 0)] [1 − 𝑃 (𝑋6 = 0)] [1 − 𝑃 (𝑋4 = 0)]
= [1 − Bin (0; 9, 1/10)] [1 − Bin (0; 6, 1/10)] [1 − Bin (0; 4, 1/10)]
" 9# " 6# " 4#
9 9 9
= 1− 1− 1− ≈ 0.08
10 10 10