Let T=X+Y, and show that E(T)=E(X)+E(Y).
We will also show that E(cX)=cE(X).
In general, we'd like to be in a position where
∑ttP(T=t)?=∑xxP(X=x)+∑yyP(Y=y)so, let's try attacking this from the l.h.s.
Considering the image above of a discrete r.v. in Pebble World, note that
E(X)=∑xxP(X=x)grouping the pebbles per X value; weighted average=∑sX(s)P({s})ungrouped; sum each pebble separately⇒E(T)=∑s(X+Y)(s)P({s})=∑sX(s)P({s})+∑sY(s)P({s})=∑xxP(X=x)+∑yyP(Y=y)=E(X)+E(Y) ◼⇒E(cX)=∑xcxP(X=x)=c∑xxP(X=x)=cE(X) ◼A misnomer: this distribution is actually non-negative, and neither is it binomial.
The Negative Binomial is a generalization of the Geometric distribution, where we have a series of independent Bern(p) trials and we want to know # failures before the rth success.
We can codify this using a bit string:
10001001000010010 denotes failure, 1 denotes successr=5n=11failuresNote that the very last bit position is, of course, a success.
Note also that we can permutate the preceding r−1 successes amongst the n+r−1 slots that come before that final rth success.
X∼NB(r,p)
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,
AutoMinorLocator)
from scipy.stats import nbinom
%matplotlib inline
plt.xkcd()
_, ax = plt.subplots(figsize=(12,8))
# seme Negative Binomial parameters
r_values = [1, 2, 4, 8]
p_values = [0.25]*len(r_values)
#p_values = [0.25, 0.24, 0.23, 0.22]
params = list(zip(r_values, p_values))
# colorblind-safe, divergent color scheme
colors = ['#018571', '#80cdc1', '#dfc27d', '#a6611a']
for i,(r,p) in enumerate(params):
x = np.arange(nbinom.ppf(0.01, r, p), nbinom.ppf(0.99, r, p))
pmf = nbinom.pmf(x, r, p)
ax.plot(x, pmf, 'o', color=colors[i], ms=8, label='r={}, p={}'.format(r,p))
ax.vlines(x, 0, pmf, lw=2, color=colors[i], alpha=0.3)
# legend styling
legend = ax.legend()
for label in legend.get_texts():
label.set_fontsize('large')
for label in legend.get_lines():
label.set_linewidth(1.5)
# y-axis
ax.set_ylim([0.0, 0.251])
ax.set_ylabel(r'$P(X=n)$')
# x-axis
ax.set_xlim([0, 55])
ax.set_xlabel(r'total # of failures $n$ before seeing $r^{th}$ success')
# x-axis tick formatting
majorLocator = MultipleLocator(5)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(1)
ax.xaxis.set_major_locator(majorLocator)
ax.xaxis.set_major_formatter(majorFormatter)
ax.xaxis.set_minor_locator(minorLocator)
ax.grid(color='grey', linestyle='-', linewidth=0.3)
plt.suptitle(r'Negative Binomial PMF: $P(X=n) = \binom{n+r-1}{r-1} p^r (1-p)^n$')
plt.show()
X∼FS(p) is the geometric distribution that counts the trials until first success, including that first success.
Let Y=X−1.
Then Y∼Geom(p)
Expected value of FS(p) is
E(X)=E(Y)+1=qp+1=1pConsider a random permutation of 1,2,3,…,n, where n≥2.
Find expected # local maxima. For example, given the permuation 3 2 1 4 7 5 6 we have 3 local maxima:
Now, there are 2 kinds of cases we need to consider:
Let Ij be the indicator r.v. of position j having a local maximum, 1≤j≤n.
Using Linearity, we can say that the expected number of local maxima is given by
E(Ij)=E(I1+I2+⋯+In)=E(I1)+E(I2)+⋯+E(In)by Linearity=(n−2)13+212=n+13Idiot-checking this, we have:
E(In=2)=2+13... case where n=2=1E(In=∞)=∞+13... case where n=∞=∞Consider a game of chance involving a fair coin. We will flip the coin until the very first heads shows (hypergeometric distribution).
So you will get $2n if the first heads shows up on the nth trial, including the heads flip.
How much would you be willing to pay to play this game?
Let's tackle this by thinking about the expected amount of
Given Y=2n, find E(Y):
E(Y)=∞∑k=12k12k−1 12=∞∑k=12k12k=∞∑k=11E(Yk=40)=40∑k=11=40So, the "paradox" here is that even if we capped the payout to 240≈$1000000000, Linearity shows us we would only pay $40. It is very hard to grasp this, but the truth is that if you were offered this game at any price, you should take it.
View Lecture 10: Expectation Continued | Statistics 110 on YouTube.