Probability Ross Chapter 5 Problems

19 Apr 2018

In [1]: from sympy import binomial as binom, N

In [2]: winom=lambda n,i: N(binom(n,i))

In [3]: from numpy import power as pw

In [4]: brv=lambda n=10,i=0,p=1/2:winom(n,i)*pw(p,i)*pw(1-p,n-i)

In [5]: sum([brv(10,i,7/10) for i in range(7,11)])
Out[5]: 0.649610718400000

(5.1)

$$ 1=\int_{-1}^{1}c(1-x^2)dx=c\int_{-1}^{1}(1-x^2)dx=c\Bop\int_{-1}^{1}dx-\int_{-1}^{1}x^2dx\Bcp $$

$$ =c\bop x\bigbar_{-1}^1-\frac{x^3}3\bigbar_{-1}^1\bcp=c\Bocb 1-(-1)-\Bosb\frac13-\Bop-\frac13\Bcp\Bcsb \Bccb=c\bop2-\frac23\bcp=\frac43c $$

So $c=\frac34$ and the CDF is

$$ F(x)=\cases{0&x\leq-1\\\int_{-1}^{x}\frac34(1-t^2)dt&-1<x<-1\\1&x\geq1} $$

(5.2)

We can compute the indefinite integral using Integration by Parts.

$$ u=x\quad\quad du=dx\quad\quad dv=e^{-\frac{x}2}dx\quad\quad v=-2e^{-\frac{x}2} $$

$$ \int xe^{-\frac{x}2}dx=\int udv=uv-\int vdu=-2xe^{-\frac{x}2}-\int-2e^{-\frac{x}2}dx $$

$$ =-2xe^{-\frac{x}2}+2\int e^{-\frac{x}2}dx=-2xe^{-\frac{x}2}+2\bop-2e^{-\frac{x}2}\bcp=-2xe^{-\frac{x}2}-4e^{-\frac{x}2} \tag{5.2.1} $$

Let’s check the antiderivative:

$$ \wdervb{x}{-2xe^{-\frac{x}2}-4e^{-\frac{x}2}}=-2e^{-\frac{x}2}+xe^{-\frac{x}2}+2e^{-\frac{x}2}=xe^{-\frac{x}2} $$

And now we compute the definite integral to find $C$:

$$ 1=\int_{0}^{\infty}Cxe^{-\frac{x}2}dx=C\int_{0}^{\infty}xe^{-\frac{x}2}dx=C\Bop -2xe^{-\frac{x}2}-4e^{-\frac{x}2} \Bcp\bigbar_{0}^{\infty}=4C $$

So $C=\frac14$ and

$$ P\set{X\geq5}=1-F(5)=1-\Bop -\frac12xe^{-\frac{x}2}-e^{-\frac{x}2} \Bcp\bigbar_{0}^{5} $$

In [360]: f=lambda x:-(1/2)*x*exp(-x/2)-exp(-x/2)

In [361]: 1-(f(5)-f(0))
Out[361]: 0.28729749518364578

Or

$$ P\set{X\geq5}=\frac14\int_{5}^{\infty}xe^{-\frac{x}2}dx=\Bop -\frac12xe^{-\frac{x}2}-e^{-\frac{x}2} \Bcp\bigbar_{5}^{\infty} $$

In [362]: f(1e+10)-f(5)
Out[362]: 0.28729749518364578

(5.3)

$$ f(2)=C\bop2\wts2-2^3\bcp=-4C\geq0\iff C\leq0 $$

$$ f(1)=C\bop2\wts1-1^3\bcp=C\geq0\iff C\geq0 $$

So there is no nonzero $C$ such that $f$ is nonnegative for all values of $x$. Hence $f$ cannot be a probability density function.

Similarly

$$ f\Bop\frac94\Bcp=C\bop2\wts\frac94-\Bop\frac94\Bcp^2\bcp=C\Bop\frac{72}{16}-\frac{81}{16}\Bcp=-\frac9{16}C\geq0\iff C\leq0 $$

$$ f(1)=C\bop2\wts1-1^2\bcp=C\geq0\iff C\geq0 $$

Again there is no nonzero $C$ such that $f$ is nonnegative for all values of $x$.

(5.4)

$$ P\set{X>20}=\int_{20}^{\infty}\frac{10}{x^2}dx=-10\bop x^{-1}\bcp\bigbar_{20}^{\infty}=-10\Bop0-\frac1{20}\Bcp=\frac12 $$

$$ \int_{10}^{t}\frac{10}{x^2}dx=-10\bop x^{-1}\bcp\bigbar_{10}^t=-10\Bop\frac1t-\frac1{10}\Bcp=1-\frac{10}t $$

$$ F(t)=\cases{0&x\leq10\\1-\frac{10}t&x>10} $$

The probability that one will function for at least $15$ hours is

$$ p\equiv P\set{X\geq15}=-10\bop x^{-1}\bcp\bigbar_{15}^{\infty}=-10\Bop0-\frac1{15}\Bcp=\frac23 $$

Let’s assume that each of the $6$ such devices will function/fail independently of the others. Then this is a binomal random variable with parameter $n=6$ and $p=\frac23$. Hence

$$ P\settx{at least 3 function for at least 15 hours}=\sum_{i=3}^{6}\binom6ip^i(1-p)^{6-i} $$

In [398]: f=lambda n,p,i:binom(n,i)*pw(p,i)*pw(1-p,n-i)

In [399]: wlt=[f(6,2/3,i) for i in range(3,7)]

In [400]: wlt
Out[400]: [0.219478737997257, 0.329218106995885, 0.263374485596708, 0.0877914951989026]

In [401]: sum(wlt)
Out[401]: 0.899862825788752

(5.5)

Let’s compute the indefinite integral of the density with substituion:

$$ y=1-x\dq x=1-y\dq dx=-dy $$

$$ 5\int(1-x)^4dx=-5\int y^4dy=-5\wts\frac{y^5}5=-(1-x)^5 $$

And then verify that the density integrates to $1$:

$$ 5\int_{0}^{1}(1-x)^4dx=\prn{-(1-x)^5}\bigbar_{0}^{1}=(1-x)^5\bigbar_1^0=1^5-0^5=1 $$

We want to find the capacity $C$ such that

$$ 0.01=\pr{X\geq C}=5\int_{C}^{1}(1-x)^4dx=\prn{-(1-x)^5}\eval{C}{1}=(1-x)^5\eval{1}{C}=(1-C)^5-0^5 $$

Hence

$$ (1-C)^5=0.01\iff1-C=0.01^{\frac15}\iff C=1-0.01^{\frac15} $$

In [21]: 1-np.float_power(.01,1/5)
Out[21]: 0.60189282944650269

(5.6.a)

$$ \evw{X}=\frac14\int_0^{\infty}x^2e^{-\frac{x}2}dx $$

Let’s compute the antiderivative using integration by parts

$$ u=x^2\quad\quad du=2xdx\quad\quad dv=e^{-\frac{x}2}dx\quad\quad v=-2e^{-\frac{x}2} $$

$$ \int x^2e^{-\frac{x}2}dx=\int udv=uv-\int vdu=-2x^2e^{-\frac{x}2}-\int-4xe^{-\frac{x}2}dx $$

$$ =-2x^2e^{-\frac{x}2}+4\int xe^{-\frac{x}2}dx $$

$$ =-2x^2e^{-\frac{x}2}+4\prn{-2xe^{-\frac{x}2}-4e^{-\frac{x}2}} \tag{follows from 5.2.1} $$

$$ =-2x^2e^{-\frac{x}2}-8xe^{-\frac{x}2}-16e^{-\frac{x}2} $$

So the expected value is

$$ \evw{X}=\frac14\bop-2x^2e^{-\frac{x}2}-8xe^{-\frac{x}2}-16e^{-\frac{x}2}\bcp\bigbar_{0}^{\infty} $$

$$ =\bop-\frac12x^2e^{-\frac{x}2}-2xe^{-\frac{x}2}-4e^{-\frac{x}2}\bcp\bigbar_{0}^{\infty} $$

$$ =0-(-4)=4 $$

Another way to compute this expectation is to recognize that this is the thinly disguised Gamma function. Recall that the Gamma function looks like this

$$ \Gamma(\alpha)=\int_0^{\infty}y^{\alpha-1}e^{-y}dy $$

And our expected value is

$$ \evw{X}=\frac14\int_0^{\infty}x^2e^{-\frac{x}2}dx $$

Integration by Substitution gives

$$ y=\frac{x}2 \quad\quad x=2y \quad\quad dx=2dy $$

$$ x_0=0\implies y_0=\frac{x_0}2=0\quad\quad x_1=\infty\implies y_1=\frac{x_1}2=\infty $$

$$ \evw{X}=\frac14\int_0^{\infty}(2y)^2e^{-y}2dy=\frac{2^3}4\int_0^{\infty}y^2e^{-y}dy $$

$$ =2\wts\Gamma(3)=2\wts(3-1)!=4 $$

(5.6.b)

In problem (5.1), we determined that $c=\frac34$. Hence

$$ \evw{X}=\frac34\int_{-1}^1x(1-x^2)dx=\frac34\Bosb\int_{-1}^1xdx-\int_{-1}^1x^3dx\Bcsb $$

$$ =\frac34\Bosb\frac{x^2}2\bigbar_{-1}^1-\frac{x^4}4\bigbar_{-1}^1\Bcsb=0 $$

(5.6.c)

$$ \evw{X}=\int_5^{\infty}x\frac5{x^2}dx=5\int_5^{\infty}\frac{dx}x=5\bop\ln(\infty)-\ln(5)\bcp=\infty $$

(5.7)

$$ \frac35=\evw{X}=\int_0^{1}x\bop a+bx^2 \bcp dx=a\int_0^1xdx+b\int_0^1x^3dx $$

$$ =a\frac{x^2}2\bigbar_0^1+b\frac{x^4}4\bigbar_0^1=\frac{a}2+\frac{b}4=\frac{2a+b}4 $$

So

$$ 10a+5b=12 $$

We also have

$$ 1=\int_0^1\bop a+bx^2\bcp dx=a\int_0^1dx+b\int_0^1x^2dx=a+b\frac{x^3}3\bigbar_0^1=a+\frac{b}3 $$

Solving the linear system, we get

$$ \bmtrx{1&\frac13&1\\10&5&12}\goesto\bmtrx{1&\frac13&1\\0&5-\frac{10}3&2}\goesto\bmtrx{1&\frac13&1\\0&\frac53&2} $$

$$ \goesto\bmtrx{1&\frac13&1\\0&1&2\wts\frac35}\goesto\bmtrx{1&\frac13&1\\0&1&\frac65}\goesto\bmtrx{1&0&1-\frac65\frac13\\0&1&\frac65} $$

$$ \goesto\bmtrx{1&0&1-\frac6{15}\\0&1&\frac65}\goesto\bmtrx{1&0&1-\frac25\\0&1&\frac65}\goesto\bmtrx{1&0&\frac35\\0&1&\frac65} $$

So $a=\frac35$ and $b=\frac65$.

(5.8)

Similar to the two alternative computations from problem (5.6.a):

$$ \evw{X}=\int_0^{\infty}x^2e^{-x}dx=\Gamma(3)=2!=2 $$

(5.9)

If $s$ units are stocked and the demand is $X$, then the profit, denoted by $Q(s)$, is

$$ Q(s)=\cases{bX-(s-X)l&X\leq s\\sb&X>s} $$

We need a theorem analogous to Proposition 4.1. It is LOTUS, the Law Of The Unconscious Statistician. Here and here are helpful links.

LOTUS is presented on p.191, Proposition 2.1

The expected profit is

$$ \evw{Q(s)}=\int_0^s\bop bx-(s-x)l\bcp f(x)dx+\int_s^{\infty}sbf(x)dx \tag{by LOTUS} $$

$$ =(b+l)\int_0^sxf(x)dx-sl\int_0^sf(x)dx+sb\Bosb1-\int_0^sf(x)dx\Bcsb $$

$$ =sb+(b+l)\int_0^sxf(x)dx-l\int_0^ssf(x)dx-b\int_0^ssf(x)dx $$

$$ =sb+(b+l)\int_0^sxf(x)dx-(b+l)\int_0^ssf(x)dx $$

$$ =sb+(b+l)\Bocb\int_0^sxf(x)dx-\int_0^ssf(x)dx\Bccb $$

$$ =sb+(b+l)\int_0^s(x-s)f(x)dx $$

To find the critical points, we set the derivative to zero:

$$ 0=\wdervb{s}{\evw{Q(s_0)}}=b+(b+l)\wdervBcb{s}{\int_0^{s_0}xf(x)dx-s_0\int_0^{s_0}f(x)dx} $$

$$ =b+(b+l)\Bocb s_0f(s_0)-\Bop\int_0^{s_0}f(x)dx+s_0f(s_0)\Bcp\Bccb $$

$$ =b-(b+l)\int_0^{s_0}f(x)dx $$

Which is equivalent to

$$ (b+l)\int_0^{s_0}f(x)dx=b $$

Or

$$ \int_0^{s_0}f(x)dx=\frac{b}{b+l} \tag{5.9.1} $$

To determine whether $s_0$ is a local max or local min, we can do the second derivative test:

$$ \wdervbn{s}{\evw{Q(s)}}{2}=-(b+l)f(s)\leq0 $$

The last inequality follows because $b$ and $l$ are positive and the probability density function is always nonnegative. Hence the expected profit is concave on $[0,\infty)$. Hence $s_0$ is the global max point of the expected profit. That is, the maximal expected profit is attained when setting $s=s_0$, the point satisfying 5.9.1.

When we evaluate the distribution of demand at the profit-maximizing number of stocked units $s_0$, we see that

$$ F(s_0)=\int_0^{s_0}f(x)dx=\frac{b}{b+l} $$

Notice what this says: At the maximal expected profit, the probability that demand will be less than or equal to the number of stocked units $s_0$ is $\frac{b}{b+l}$.

(5.10.a)

Let $X$ denote the time the passenger arrives. Then $X\uda{0}{60}$.

7:00-7:05 B
7:06-7:15 A 10
7:16-7:20 B
7:21-7:30 A 10
7:31-7:35 B
7:36-7:45 A 10
7:46-7:50 B
7:51-8:00 A 10

$$ \pr{5<X<15}+\pr{20<X<30}+\pr{35<X<45}+\pr{50<X<60} $$

$$ =\frac1{60-0}\Prn{\int_{5}^{15}dx+\int_{20}^{30}dx+\int_{35}^{45}dx+\int_{50}^{60}dx}=\frac{40}{60}=\frac23 $$

He goes to destination A two-thirds of the time.

(5.10.b)

Same idea:

7:10-7:15 A 5
7:16-7:20 B
7:21-7:30 A 10
7:31-7:35 B
7:36-7:45 A 10
7:46-7:50 B
7:51-8:00 A 10
8:01-8:05 B
8:06-8:10 A 5

He goes to destination A two-thirds $\bop\frac{40}{60}\bcp$ of the time.

(5.11)

Interpretation: Uniformly distributed.

When $X<\frac{L}5$, the shorter-to-longer ratio will be less than $\frac14$:

$$ X<\frac{L}5\implies-X>-\frac{L}5 $$

$$ \implies L-X>L-\frac{L}5=\frac{5L-L}5=\frac{4L}5 $$

$$ \implies\frac1{L-X}<\frac1{\frac{4L}5} $$

$$ \implies\frac{X}{L-X}<\frac{X}{\frac{4L}5}<\frac{\frac{L}5}{\frac{4L}5}=\frac{L}{4L}=\frac14 $$

Similarly, when $X>\frac{4L}5$, the shorter-to-longer ratio will be less than $\frac14$:

$$ X>\frac{4L}5\implies-X<-\frac{4L}5\quad\text{and}\quad\frac1{X}<\frac1{\frac{4L}5} $$

$$ \implies L-X<L-\frac{4L}5=\frac{L}5 $$

$$ \implies \frac{L-X}X=\frac1{X}(L-X)<\frac1{X}\frac{L}5<\frac1{\frac{4L}5}\frac{L}5=\frac5{4L}\frac{L}5=\frac14 $$

But when $\frac{L}5<X<\frac{4L}5$, the shorter-to-longer ratio is greater than $\frac14$:

$$ \frac{L}5<X<\frac{4L}5\implies-\frac{L}5>-X>-\frac{4L}5 $$

$$ \implies \frac{4L}5=L-\frac{L}5>L-X>L-\frac{4L}5=\frac{L}5 $$

$$ \implies \frac1{\frac{4L}5}<\frac1{L-X}<\frac1{\frac{L}5} $$

$$ \implies \frac14=\frac{L}5\frac5{4L}=\frac{\frac{L}5}{\frac{4L}5}<\frac{X}{\frac{4L}5}<\frac{X}{L-X}<\frac{X}{\frac{L}5}<\frac{\frac{4L}5}{\frac{L}5}=\frac{4L}5\frac5{L}=4 $$

$$ \implies\frac{X}{L-X}>\frac14\quad\quad\text{and}\quad\quad\frac{L-X}{X}>\frac14 $$

Hence the desired probability is

$$ P\settx{ratio of shorter/longer is less than 1/4}=P\Bset{X<\frac{L}5}+P\Bset{X>\frac{4L}5}=\frac15+\frac15=\frac25 $$

Or

$$ P\settx{ratio of shorter/longer is less than 1/4}=1-P\Bset{\frac{L}5<X<\frac{4L}5} $$

$$ =1-\frac{\frac{4L}5-\frac{L}5}{L}=1-\frac{3L}5\frac1L=1-\frac35=\frac25 $$

More compact solution:

$$ P\settx{ratio of shorter/longer is less than 1/4}=\prB{\min\Bop\frac{X}{L-X},\frac{L-X}{X}\Bcp<\frac14} $$

$$ =1-\prB{\min\Bop\frac{X}{L-X},\frac{L-X}{X}\Bcp>\frac14} $$

$$ =1-\prB{\frac{X}{L-X}>\frac14,\frac{L-X}{X}>\frac14} $$

$$ =1-\prB{X>\frac14L-\frac14X,L-X>\frac14X} $$

$$ =1-\prB{\frac54X>\frac14L,L>\frac54X} $$

$$ =1-\prB{5X>L,4L>5X} $$

$$ =1-\prB{X>\frac{L}5,\frac{4L}5>X} $$

$$ =1-\prB{\frac{L}5<X<\frac{4L}5}=1-\frac{\frac{4L}5-\frac{L}5}{L}=1-\frac{3L}5\frac1L=1-\frac35=\frac25 $$

(5.12)

Let $X$ denote the location of the breakdown. $X$ is uniformly distributed over $(0,100)$ hence

$$ f(x)=\frac1{100-0}=\frac1{100} $$

$$ F(x)=\int_{0}^{x}f(t)dt=\frac1{100}\int_0^xdt=\frac1{100}t\eval{0}{x}=\frac{x}{100} $$

In the current scenario, there are stations at $0,50,$ and $100$ miles. Let $Y=g(X)$ denote the distance to the nearest station from the breakdown location $X$. Then

$$ Y=g(X)=\cases{X&X\leq25\\50-X&25<X\leq50\\X-50&50<X\leq75\\100-X&75<X} $$

We can use LOTUS to compute the expected distance to the nearest station from the breakdown location:

LOTUS is presented on p.191, Proposition 2.1

$$ \evw{Y}=\evw{g(X)}=\int_{0}^{100}g(x)f(x)dx $$

$$ =\int_{0}^{25}xf(x)dx+\int_{25}^{50}(50-x)f(x)dx+\int_{50}^{75}(x-50)f(x)dx+\int_{75}^{100}(100-x)f(x)dx $$

$$ =\frac1{100}\Bop\int_{0}^{25}xdx+\int_{25}^{50}(50-x)dx+\int_{50}^{75}(x-50)dx+\int_{75}^{100}(100-x)dx\Bcp $$

$$ =\frac1{100}\Bop\frac{x^2}2\bigbar_{0}^{25}+50x\bigbar_{25}^{50}-\frac{x^2}2\bigbar_{25}^{50}+\frac{x^2}2\bigbar_{50}^{75}-50x\bigbar_{50}^{75}+100x\bigbar_{75}^{100}-\frac{x^2}2\bigbar_{75}^{100}\Bcp $$

$$ =\frac1{100}\Bop\frac{x^2}2\bigbar_{0}^{25}-\frac{x^2}2\bigbar_{25}^{50}+\frac{x^2}2\bigbar_{50}^{75}-\frac{x^2}2\bigbar_{75}^{100}+50x\bigbar_{25}^{50}-50x\bigbar_{50}^{75}+100x\bigbar_{75}^{100}\Bcp $$

$$ =\frac1{100}\Bop\frac{2\wts 25^2}2-\frac{2\wts 50^2}2+\frac{2\wts 75^2}2-\frac{100^2}2-50\wts25+2\wts50^2-50\wts75+100^2-100\wts75\Bcp $$

$$ =\frac1{100}\Bop\frac{100^2}2+25^2-50^2+75^2-50\wts25+2\wts50^2-50\wts75-100\wts75\Bcp $$

$$ =\frac1{100}\Bop\frac{100^2}2+25^2+50^2+75^2-50\wts25-150\wts75\Bcp $$

$$ =\frac1{100}\Bop\frac{100^2}2+25^2+50^2+75^2-2\wts25\wts25-2\wts75\wts75\Bcp $$

$$ =\frac1{100}\Bop\frac{100^2}2-25^2+50^2-75^2\Bcp $$

In [477]: (1/100)*(pw(100,2)/2-pw(25,2)+pw(50,2)-pw(75,2))
Out[477]: 12.5

In the proposed scenario, there are stations at $25,50,$ and $75$ miles. Let $Z=h(X)$ denote the distance to the nearest station from the breakdown location $X$. Then

$$ Z=h(X)=\cases{25-X&X\leq25\\X-25&25<X\leq37.5\\50-X&37.5<X\leq50\\X-50&50<X\leq62.5\\75-X&62.5<X\leq75\\X-75&75<X} $$

Using LOTUS again to compute the expected distance to the nearest station from the breakdown location:

LOTUS is presented on p.191, Proposition 2.1

$$ \evw{Z}=\evw{h(X)}=\int_{0}^{100}h(x)f(x)dx $$

In [474]: import scipy.integrate as integrate

In [475]: I=lambda f_x,a,b: integrate.quad(f_x,a,b)[0]

In [476]: (1/100)*(I(lambda x:25-x,0,25)+I(lambda x:x-25,25,37.5)+I(lambda x:50-x,37.5,50)+I(lambda x:x-50,50,62.5
     ...: )+I(lambda x:75-x,62.5,75)+I(lambda x:x-75,75,100))
Out[476]: 9.375

So, yes, it would be more efficient to have the stations rearranged in the proposed fashion.

(5.13)

$X~\uda{0}{30}$

$$ \pr{X>10}=\frac1{30}\int_{10}^{30}dx=\frac{20}{30}=\frac23 $$

$$ \cp{X>25}{X>15}=\frac{\pr{X>25,X>15}}{\pr{X>15}}=\frac{\pr{X>25}}{\pr{X>15}}=\frac{\frac1{30}\int_{25}^{30}dx}{\frac1{30}\int_{15}^{30}dx}=\frac5{15}=\frac13 $$

(5.14)

Since $X$ is uniformly distributed on $(0,1)$, its density function is $f_X(x)=\frac1{1-0}=1$ for all $x\in(0,1)$. Let $g(x)=x^n$. Then

$$ \E{g(X)}=\int_{0}^{1}g(x)f_X(x)dx=\int_{0}^{1}x^ndx=\frac{x^{n+1}}{n+1}\bigbar_{0}^{1}=\frac1{n+1} $$

To compute this directly, we first determine the CDF $F_{g(X)}$ of $g(X)$. For a fixed $x_0\in(0,1)$, we have

$$ F_{g(X)}(x_0)=P\set{g(X)\leq x_0} $$

$$ =P\set{X^n\leq x_0} $$

$$ =P\set{X\leq x_0^{\frac1n}} $$

$$ =\int_{0}^{x_0^{\frac1n}}f_X(x)dx=x\eval{0}{x_0^{\frac1n}}=x_0^{\frac1n} $$

To determine the density of $g(X)$, we differentiate this:

$$ f_{g(X)}(x_0)=\wdervb{x}{F_{g(X)}(x_0)}=\frac1nx_0^{\frac1n-1}=\frac{x_0^{\frac1n-1}}n $$

And compute the expectation directly:

$$ \E{g(X)}=\int_{0}^{1}xf_{g(X)}(x)dx=\int_{0}^{1}x\frac{x^{\frac1n-1}}ndx=\frac1n\int_{0}^{1}x^{\frac1n}dx=\frac1n\frac{x^{\frac1n+1}}{\frac1n+1}\bigbar_{0}^{1}=\frac1{n+1} $$

(5.15)

$$ \Phi(x)=\frac1{\sqrt{2\pi}}\int_{-\infty}^{x}e^{-\frac{y^2}{2}}dy=\pr{Z\leq x} $$

Proposition

$$ \Phi(-x)=1-\Phi(x) $$

Proof

$$ 1-\Phi(x)=1-\frac1{\sqrt{2\pi}}\int_{-\infty}^{x}e^{-\frac{y^2}{2}}dy=\frac1{\sqrt{2\pi}}\int_{x}^{\infty}e^{-\frac{y^2}{2}}dy=P\set{Z>x} $$

$$ \Phi(-x)=\frac1{\sqrt{2\pi}}\int_{-\infty}^{-x}e^{-\frac{y^2}{2}}dy=P\set{Z\leq-x} $$

So it suffices to show that

$$ \int_{-\infty}^{-x}e^{-\frac{y^2}{2}}dy=\int_{x}^{\infty}e^{-\frac{y^2}{2}}dy $$

$$ u=-y\dq y=-u\dq dy=-du\dq u_0=-y_0=--\infty=\infty\dq u_1=-y_1=--x=x $$

$$ \int_{-\infty}^{-x}e^{-\frac{y^2}{2}}dy=-\int_{\infty}^{x}e^{-\frac{(-u)^2}{2}}du=-\int_{\infty}^{x}e^{-\frac{u^2}{2}}du=\int_{x}^{\infty}e^{-\frac{u^2}{2}}du $$

$\wes$

Using this and letting $X\nd$ with $\mu=10$ and $\sigma^2=36$, we can compute

$$ P\set{X>5}=P\Bset{\frac{X-\mu}{\sigma}>\frac{5-\mu}{\sigma}}=P\Bset{\frac{X-10}{6}>\frac{5-10}{6}}=P\Bset{Z>-\frac56} $$

$$ =1-P\Bset{Z\leq-\frac56}=1-\Phi\Bop-\frac56\Bcp=1-\bop1-\Phi\Bop\frac56\Bcp\bcp=\Phi\Bop\frac56\Bcp $$

In [485]: from scipy.stats import norm

In [486]: norm(0, 1).cdf(5/6)
Out[486]: 0.79767161903635686

$$ P\set{4<X<16}=P\Bset{\frac{4-10}6<\frac{X-10}6<\frac{16-10}6}=P\set{-1<Z<1} $$

$$ =P\set{Z<1}-P\set{Z<-1}=\Phi(1)-\Phi(-1)=\Phi(1)-(1-\Phi(1))=2\Phi(1)-1 $$

In [489]: 2*norm(0, 1).cdf(1)-1
Out[489]: 0.68268949213708585

$$ P\set{X<8}=P\Bset{\frac{X-10}6<\frac{8-10}6}=P\Bset{Z<-\frac13}=\Phi\Bop-\frac13\Bcp=1-\Phi\Bop\frac13\Bcp $$

In [490]: 1-norm(0,1).cdf(1/3)
Out[490]: 0.36944134018176367

$$ P\set{X<20}=P\Bset{\frac{X-10}6<\frac{20-10}6}=P\Bset{Z<\frac53}=\Phi\Bop\frac53\Bcp $$

In [491]: norm(0,1).cdf(5/3)
Out[491]: 0.9522096477271853

$$ P\set{X>16}=P\Bset{\frac{X-10}6>\frac{16-10}6}=P\set{Z>1}=1-P\set{Z<1}=1-\Phi(1) $$

In [496]: phi=lambda x:norm(0,1).cdf(x)

In [497]: 1-phi(1)
Out[497]: 0.15865525393145707

(5.16)

The probability that it will rain more than $50$ inches in a given year is

$$ P\set{X>50}=P\Bset{\frac{X-40}4>\frac{50-40}4}=P\Bset{Z>\frac52}=1-P\Bset{Z<\frac52}=1-\Phi\Bop\frac52\Bcp $$

In [498]: 1-phi(5/2)
Out[498]: 0.0062096653257761592

And the probability $p\approx0.99379$ that it will rain less than $50$ inches in a give year is computed as

In [499]: phi(5/2)
Out[499]: 0.99379033467422384

We wish to compute the probability that it will rain less than $50$ inches every year for $10$ years in a row. If we assume independence of rainfall from year-to-year, this is a Binomial distribution with parameters $n=10$ and $p\approx0.99379$.

$$ P\settx{rain less than 50 inches 10 years in a row}=p^{10}\approx0.93961 $$

In [500]: pw(phi(5/2),10)
Out[500]: 0.93961012080442396

(5.17)

Let $X\uda{0}{10}$ denote the distance from the shot to the target. Its density is $f(x)=\frac1{10}$. Let $g(X)$ denote the points scored for a given distance. Then

$$ g(X)=\cases{10&X\leq1\\5&1<X\leq3\\3&3<X\leq5\\0&5<X\leq10} $$

$$ \E{g(X)}=\int_0^{10}g(x)f(x)dx=\frac{10}{10}\int_0^1dx+\frac{5}{10}\int_1^3dx+\frac3{10}\int_3^5dx $$

$$ =(1-0)+\frac12(3-1)+\frac3{10}(5-3)=1+1+\frac35=2.6 $$

(5.18)

$$ 0.2=P\set{X>9}=P\Bset{Z>\frac{9-5}{\sigma}}=P\Bset{Z>\frac4{\sigma}}=1-P\Bset{Z<\frac4{\sigma}} $$

$$ \Phi\Bop\frac4{\sigma}\Bcp=P\Bset{Z<\frac4{\sigma}}=1-0.2=0.8 $$

In [102]: def find_phi_x(y,tol=1e-8):
     ...:     err,x,cnt=9.9,1.0,0
     ...:     while abs(err)>tol:
     ...:         cnt+=1
     ...:         err=y-phi(x)
     ...:         x+=err
     ...:     return (cnt,x,err)
     ...: 

In [103]: find_phi_x(.8)
Out[103]: (48, 0.84162125838389479, -9.6468919519310248e-09)

Hence $\frac4{\sigma}\approx0.8416212\iff\sigma\approx\frac4{0.841621}\implies\sigma^2\approx\Bop\frac4{0.841621}\Bcp^2$.

In [527]: pw(4/0.841621,2)
Out[527]: 22.588472096532808

(5.19)

$$ 0.1=P\set{X>c}=P\Bset{Z>\frac{c-12}{\sqrt{4}}}=1-P\Bset{Z<\frac{c-12}2} $$

$$ P\Bset{Z<\frac{c-12}2}=1-0.1=0.9 $$

In [105]: find_phi_x(.9)
Out[105]: (80, 1.2815515202900345, 9.6326077114738951e-09)

Let $p=1.2815515$. Then

$$ \frac{c-12}2\approx p $$

$$ c-12\approx2p $$

$$ c\approx2p+12=14.56310304 $$

In [106]: 2*1.2815515202900345+12
Out[106]: 14.563103040580069

(5.20.a)

Let $N$ denote the population of the large community. And let $n=100$ denote the sample size.

Let $S_n$ denote the number of people in the sample who are in favor of the proposed rise in school taxes. Then $S_n$ is a hypergeometric random variable. That is, $S_n$ has the same distribution as the number of white balls obtained when $n=100$ balls are chosen from an urn of $N$ balls, of which $0.65N$ are white.

But because $N$ and $0.65N$ are both large in comparison with the sample size $n=100$, it follows from the binomial approximation to the hypergeometric (see Section 4.8.3) that the distribution of $S_n$ is closely approximated by a binomial distribution with parameters $n=100$ and $p=0.65$.

The binomial random variable with parameters $n=100$ and $p=0.65$ has mean $\mu=np=65$ and standard deviation $\sigma=\sqrt{np(1-p)}=\sqrt{100\wts0.65\wts0.35}\approx4.77$. And the normal approximation to the binomial distribution then shows that

$$ \pr{S_{100}\geq50}=\pr{S_{100}>49.5} \tag{continuity correction p205} $$

$$ =\prB{\frac{S_{100}-\mu}{\sigma}>\frac{49.5-\mu}{\sigma}} $$

$$ =\prB{Z>\frac{49.5-\mu}{\sigma}} $$

$$ =1-\prB{Z<\frac{49.5-\mu}{\sigma}} $$

$$ =1-\Phi\Prn{\frac{49.5-\mu}{\sigma}} $$

In [128]: n,p=100,.65

In [129]: mu,sigma=n*p,np.sqrt(n*p*(1-p))

In [130]: n,p,mu,sigma
Out[130]: (100, 0.65, 65.0, 4.7696960070847281)

In [131]: pr520=lambda x: phi((x-mu)/sigma)

In [132]: 1-pr520(49.5)
Out[132]: 0.99942233140542336

In [133]: sum([brv(n,i,p) for i in range(50,n+1)])
Out[133]: 0.999262166751138

(5.20.b)

$$ \pr{60\leq S_{100}\leq70}=\pr{59.5<S_{100}<70.5} $$

$$ =\prB{\frac{59.5-\mu}{\sigma}<\frac{S_{100}-\mu}{\sigma}<\frac{70.5-\mu}{\sigma}} $$

$$ =\prB{\frac{59.5-\mu}{\sigma}<Z<\frac{70.5-\mu}{\sigma}} $$

$$ =\prB{Z<\frac{70.5-\mu}{\sigma}}-\prB{Z<\frac{59.5-\mu}{\sigma}} $$

$$ =\Phi\Prn{\frac{70.5-\mu}{\sigma}}-\Phi\Prn{\frac{59.5-\mu}{\sigma}} $$

In [134]: pr520(70.5)-pr520(59.5)
Out[134]: 0.75113612506207783

In [135]: sum([brv(n,i,p) for i in range(60,71)])
Out[135]: 0.751379089022708

(5.20.c)

$$ \pr{S_{100}<75}=\pr{S_{100}<74.5}=\Phi\Prn{\frac{74.5-\mu}{\sigma}} $$

In [138]: pr520(74.5)
Out[138]: 0.97680026906454775

In [139]: sum([brv(n,i,p) for i in range(0,75)])
Out[139]: 0.978858376346662

(5.21)

$$ \pr{X>74}=\prB{Z>\frac{74-71}{\sqrt{6.25}}}=1-\prB{Z<\frac{74-71}{\sqrt{6.25}}} $$

In [153]: phims=lambda x,mu=0,sigma=1: phi((x-mu)/sigma)

In [154]: 1-phims(74,71,np.sqrt(6.25))
Out[154]: 0.11506967022170822

$$ \cp{X>77}{X>72}=\frac{\pr{X>77,X>72}}{\pr{X>72}}=\frac{\pr{X>77}}{\pr{X>72}}=\frac{1-\pr{X<77}}{1-\pr{X<72}} $$

$$ =\frac{1-\prB{Z<\frac{77-71}{\sqrt{6.25}}}}{1-\prB{Z<\frac{72-71}{\sqrt{6.25}}}} $$

In [156]: (1-phims(77,71,np.sqrt(6.25)))/(1-phims(72,71,np.sqrt(6.25)))
Out[156]: 0.023790055596966151

(5.22.a)

Let $X$ denote the width of a slot of a randomly chosen duralumin forging. The specification limits were given as $0.9000\pm0.0050$. This is the interval $[0.895,0.905]$. I guess a forging is defective if $X$ is not in $[0.895,0.905]$:

$$ \prt{forging defective}=1-\prt{forging not defective} $$

$$ =1-\pr{0.895<X<0.905}=1-\prn{\pr{X<0.905}-\pr{X<0.895}} $$

$$ =1-\prn{\prB{Z<\frac{0.905-0.9}{0.003}}-\prB{Z<\frac{0.895-0.9}{0.003}}} $$

$$ =1-\Cbr{\snB{\frac{0.905-0.9}{0.003}}-\snB{\frac{0.895-0.9}{0.003}}} $$

In [169]: 1-(phims(.905,.9,.003)-phims(.895,.9,.003))
Out[169]: 0.095580704545629169

(5.22.b)

$$ \frac1{100}\geq1-\Cbr{\snB{\frac{0.005}{\sigma}}-\snB{-\frac{0.005}{\sigma}}} $$

$$ =1-\Cbr{\snB{\frac{0.005}{\sigma}}-\Sbr{1-\snB{\frac{0.005}{\sigma}}}} $$

$$ =1-\Cbr{\snB{\frac{0.005}{\sigma}}-1+\snB{\frac{0.005}{\sigma}}} $$

$$ =2-2\snB{\frac{0.005}{\sigma}} $$

Hence

$$ \frac1{200}\geq1-\snB{\frac{0.005}{\sigma}} $$

Or

$$ \snB{\frac{0.005}{\sigma}}\geq1-\frac1{200}=\frac{199}{200} $$

$$ \implies\frac{0.005}\sigma\approx2.5758\implies\sigma\approx\frac{0.005}{2.5758}\approx0.001941 $$

In [170]: find_phi_x(199/200)
Out[170]: (913, 2.5758286270773909, 9.9251277196898968e-09)

In [171]: .005/2.5758286270773909
Out[171]: 0.0019411229254304638

(5.23)

$$ \pr{150\leq X\leq200}=\pr{149.5<X<200.5} $$

$$ =\pr{X<200.5}-\pr{X<149.5} $$

$$ =\snB{\frac{200.5-np}{\sqrt{np(1-p)}}}-\snB{\frac{149.5-np}{\sqrt{np(1-p)}}} $$

In [181]: n,p=1000,1/6

In [182]: mu,sigma=n*p,np.sqrt(n*p*(1-p))

In [183]: n,p,mu,sigma
Out[183]: (1000, 0.16666666666666666, 166.66666666666666, 11.785113019775793)

In [184]: sum([brv(n,i,p) for i in range(150,201)])
Out[184]: 0.926453166856648

In [185]: phims(200.5,mu,sigma)-phims(149.5,mu,sigma)
Out[185]: 0.92534527994903015

Change $n=800$ and $p=\frac15$.

$$ \pr{Y<150|X=200}=\snB{\frac{149.5-np}{\sqrt{np(1-p)}}} $$

In [186]: n,p=800,1/5

In [187]: mu,sigma=n*p,np.sqrt(n*p*(1-p))

In [188]: n,p,mu,sigma
Out[188]: (800, 0.2, 160.0, 11.313708498984761)

In [189]: sum([brv(n,i,p) for i in range(0,150)])
Out[189]: 0.176984550300451

In [190]: phims(149.5,mu,sigma)
Out[190]: 0.17668364599664593

(5.24)

Let’s compute $p$, the probability that a single chip will live less than $1.8\times10^6$ hours:

$$ \pr{X<1.8\times10^6}=\snB{\frac{1.8\times10^6-1.4\times10^6}{3\times10^5}} $$

In [210]: phims(1.8*1e+6,1.4*1e+6,3*1e+5)
Out[210]: 0.90878878027413212

$$ \pr{Y\geq20}=P\set{Y>19.5}=\prB{Z>\frac{19.5-np}{\sqrt{np(1-p)}}}=1-\snB{\frac{19.5-np}{\sqrt{np(1-p)}}} $$

In [211]: n,p=100,phims(1.8*1e+6,1.4*1e+6,3*1e+5)

In [212]: mu,sigma=n*p,np.sqrt(n*p*(1-p))

In [213]: n,p,mu,sigma
Out[213]: (100, 0.90878878027413212, 90.878878027413208, 2.8790924459278364)

In [214]: sum([brv(n,i,p) for i in range(20,n+1)])
Out[214]: 1.00000000000000

In [215]: 1-phims(19.5,mu,sigma)
Out[215]: 1.0

(5.25)

$$ \pr{X\leq10}=\prB{Z<\frac{10.5-150\wts0.05}{\sqrt{150\wts0.05(1-0.05)}}}=\snB{\frac{10.5-7.5}{\sqrt{150\wts0.05(1-0.05)}}} $$

In [219]: sum([brv(150,i,.05) for i in range(0,11)])
Out[219]: 0.867784625876600

In [220]: phims(10.5,150*.05,np.sqrt(150*.05*(1-.05)))
Out[220]: 0.86947290521017129

(5.26)

$X$ is the number of heads when the fair coin is flipped $1{,}000$ times.

$$ \pr{X\geq525}=\prB{Z>\frac{524.5-1{,}000\wts\frac12}{\sqrt{1{,}000\wts\frac12\frac12}}}=1-\snB{\frac{524.5-1{,}000\wts\frac12}{\sqrt{1{,}000\wts\frac12\frac12}}} $$

$Y$ is the number of heads when the biased coin is flipped $1{,}000$ times.

$$ \pr{Y<525}=\snB{\frac{524.5-1{,}000\wts0.55}{\sqrt{1{,}000\wts0.55\wts0.45}}} $$

In [239]: sum([brv(1000,i,1/2) for i in range(525,1001)])
Out[239]: 0.0606071329055187

In [240]: 1-phims(524.5,1000*1/2,np.sqrt(1000*1/2*(1-1/2)))
Out[240]: 0.060628857725820717

In [241]: sum([brv(1000,i,.55) for i in range(0,525)])
Out[241]: 0.0526817034948391

In [242]: phims(524.5,1000*.55,np.sqrt(1000*.55*(1-.55)))
Out[242]: 0.052521001860295881

(5.27)

$$ \pr{X<5499.5}=\snB{\frac{5499.5-10{,}000\wts\frac12}{\sqrt{10{,}000\wts\frac12\frac12}}} $$

In [247]: phims(5500,10000*1/2,np.sqrt(10000*1/2*1/2))
Out[247]: 1.0

So the probability of flipping at least $5{,}500$ heads out of $10{,}000$ for a fair coin is $0$. Hence we can very confidently say that the coin is biased.

(5.28)

$$ \pr{X\geq20}=1-\pr{X<19.5}=1-\snB{\frac{19.5-200\wts0.12}{\sqrt{200\wts0.12\wts0.88}}} $$

In [253]: 1-phims(19.5,200*.12,np.sqrt(200*.12*.88))
Out[253]: 0.83625615886429205

In [254]: sum([brv(200,i,.12) for i in range(20,201)])
Out[254]: 0.836218233192810

We’re assuming that the student body represents a fair sample of the population. For instance, if this is a school for left-handed children only, obviously this wouldn’t be a fair sample.

We’re also assuming that the handedness of each child is independently left with probability $p=0.12$. This could fail if there exists a genetic predisposition to left-handedness in the local community. For instance, suppose there exists $20$ children from the $200$ students who descend from parents who are both left handed. Since the likelihood of such a child being left handed is $26\%$, then the assumptions of the binomial random variable wouldn’t hold.

(5.29)

Let $X$ denote the number days that the stock is up over the next $1{,}000$ days. Then the stock will be up at least $30$ percent after the next $1{,}000$ periods if $X$ satisfies

$$ 1.3\leq u^{X}d^{1000-X} $$

Since the log function is nondecreasing, we have

$$ \ln(1.3)\leq\ln\prn{u^{X}d^{1000-X}}=\ln\prn{u^{X}}+\ln\prn{d^{1000-X}} $$

$$ =X\ln(u)+(1000-X)\ln(d)=X\prn{\ln(u)-\ln(d)}+1000\ln(d) $$

Or

$$ X\prn{\ln(u)-\ln(d)}\geq\ln(1.3)-1000\ln(d) $$

Or

$$ X\geq\frac{\ln(1.3)-1000\ln(d)}{\ln(u)-\ln(d)} \tag{since $u>d$} $$

In [281]: from numpy import log as ln

In [282]: pr529=lambda u=1.012,d=.99:(ln(1.3)-1000*ln(d))/(ln(u)-ln(d))

In [283]: pr529()
Out[283]: 469.20896703016723

Hence, the stock will be up at least $30\%$ percent over the next $1{,}000$ periods iff $X\geq470$.

$$ \pr{X\geq470}=1-\pr{X<469.5}=1-\snB{\frac{469.5-1000\wts0.52}{\sqrt{1000\wts0.52\wts0.48}}} $$

In [284]: n,p=1000,.52

In [285]: 1-phims(469.5,n*p,np.sqrt(n*p*(1-p)))
Out[285]: 0.99930437111454296

In [286]: sum([brv(n,i,p) for i in range(470,n+1)])
Out[286]: 0.999300908477044

(5.30)

I guess this question concerns conditional distributions of joint variables, which is introduced later in the book. Glancing ahead, it looks like section 6.5 is the introduction and a particular example EXAMPLE 5c The Bivariate Normal Distribution might be applicable.

(5.31.a)

Let $X\uda{0}{A}$ denote the location of a fire along the road. Then the density is $f_X(x)=\frac1{A-0}=\frac1A$. Let $a\in[0,A]$ denote the location of the fire station. Let $g_a(X)$ denote the distance from the fire station to a fire. Then we have

$$ g_a(X)=\cases{a-X&a\geq X\\X-a&a<X}=\norm{X-a} $$

LOTUS (Proposition 2.1) tells us that the expected distance from the fire station to a fire is

$$ \E{g_a(X)}=\E{\norm{X-a}}=\int_0^A\norm{x-a}f_X(x)dx $$

$$ =\frac1A\Cbr{\int_0^a(a-x)dx+\int_a^A(x-a)dx} $$

$$ =\frac1A\Cbr{a\int_0^adx-\int_0^axdx+\int_a^Axdx-a\int_a^Adx} $$

$$ =\frac1A\Cbr{ax\eval{0}{a}-\frac{x^2}2\eval{0}{a}+\frac{x^2}2\eval{a}{A}-ax\eval{a}{A}} $$

$$ =\frac1A\Cbr{a(a-0)-\Prn{\frac{a^2}2-\frac{0^2}2}+\Prn{\frac{A^2}2-\frac{a^2}2}-a(A-a)} $$

$$ =\frac1A\Cbr{a^2-\frac{a^2}2+\frac{A^2}2-\frac{a^2}2-aA+a^2} $$

$$ =\frac1A\Cbr{a^2+\frac{A^2}2-aA} $$

$$ =\frac{a^2}A+\frac{A}2-a $$

To find the stationary points of the expected distance from a fire to the fire station, we set the derivative to zero:

$$ 0=\wdervb{a}{\E{g_a(X)}}=\frac{2a}A-1 $$

Or

$$ \frac{2a}A=1\iff 2a=A\iff a=\frac{A}2 $$

We can use the second derivative test to determine whether this is a local min or max:

$$ \wdervbn{a}{\E{g_a(X)}}{2}=\frac2A>0 $$

Hence $a_0=\frac{A}2$ is a local min. To find the global min, we just need to test the boundaries:

$$ g_{\frac{A}2}(a_0)=\frac{A}2-\frac{A}2=0 $$

$$ g_{\frac{A}2}(0)=\frac{A}2-0=\frac{A}2>0=g_{\frac{A}2}(a_0) $$

$$ g_{\frac{A}2}(A)=A-\frac{A}2=\frac{A}2>0=g_{\frac{A}2}(a_0) $$

Hence $a_0=\frac{A}2$ is the global min and we’re done.

(5.31.b)

Let $X$ denote the location of a fire along the road of infinite length. Then the density is $f_X(x)=\edn{x}$. Let $a\in[0,\infty)$ denote the location of the fire station. Let $g_a(X)$ denote the distance from the fire station to a fire. Then we have

$$ g_a(X)=\cases{a-X&a\geq X\\X-a&a<X}=\norm{X-a} $$

LOTUS (Proposition 2.1) tells us that the expected distance from the fire station to a fire is

$$ \E{g_a(X)}=\E{\norm{X-a}}=\int_0^{\infty}\norm{x-a}\edn{x}dx $$

$$ =\int_0^{a}(a-x)\edn{x}dx+\int_a^{\infty}(x-a)\edn{x}dx $$

$$ =a\int_0^{a}\edn{x}dx-\int_0^{a}x\edn{x}dx+\int_a^{\infty}x\edn{x}dx-a\int_a^{\infty}\edn{x}dx $$

$$ =a\bop\pr{X<a}-\pr{X>a}\bcp-2\int_0^{a}x\edn{x}dx+\int_0^{a}x\edn{x}dx+\int_a^{\infty}x\edn{x}dx $$

$$ =a\bop1-\pr{X>a}-\pr{X>a}\bcp-2\int_0^{a}x\edn{x}dx+\E{X} $$

$$ =a\bop1-2\pr{X>a}\bcp-2\int_0^{a}x\edn{x}dx+\frac1\lambda \tag{5.31.b.1} $$

Let’s integrate the middle term by parts:

$$ u=x\dq du=dx\dq dv=\edn{x}dx\dq v=-\e{-\lambda x} $$

$$ \int_0^{a}x\edn{x}dx=\int udv=uv-\int vdu=-x\e{-\lambda x}\eval{0}{a}+\int_0^a\e{-\lambda x}dx $$

$$ =x\e{-\lambda x}\eval{a}{0}-\frac1{\lambda}\e{-\lambda x}\eval{0}{a} $$

$$ =-a\e{-\lambda a}+\frac1{\lambda}\e{-\lambda x}\eval{a}{0} $$

$$ =-a\e{-\lambda a}+\frac1{\lambda}-\frac1{\lambda}\e{-\lambda a} $$

So 5.31.b.1 becomes

$$ \E{g_a(X)}=a\bop1-2\e{-\lambda a}\bcp-2\bop-a\e{-\lambda a}+\frac1{\lambda}-\frac1{\lambda}\e{-\lambda a}\bcp+\frac1\lambda $$

$$ =a-2a\e{-\lambda a}+2a\e{-\lambda a}-\frac2{\lambda}+\frac2{\lambda}\e{-\lambda a}+\frac1\lambda $$

$$ =a-\frac1{\lambda}+\frac2{\lambda}\e{-\lambda a} $$

To find the stationary points of the expected distance from a fire to the fire station, we set the derivative to zero:

$$ 0=\wdervb{a}{\E{g_a(X)}}=1+\frac2\lambda\e{-\lambda a}(-\lambda)=1-2\e{-\lambda a} $$

$\iff$

$$ \e{-\lambda a}=\frac12\iff-\lambda a=\ln\Bop\frac12\Bcp $$

$\iff$

$$ a=-\frac{\ln\Bop\frac12\Bcp}{\lambda}=-\frac{\ln\bop2^{-1}\bcp}{\lambda}=\frac{\ln(2)}\lambda $$

To determine whether this is a local min or max, we can do the second derivative test:

$$ \wdervbn{a}{\E{g_a(X)}}{2}=-2\e{-\lambda a}(-\lambda)=2\lambda\e{-\lambda a}>0 $$

Hence the expected distance is convex on $[0,\infty)$ and $a_0=\frac{\ln(2)}{\lambda}$ is the global min.

Let’s just check the boundary to be sure:

$$ \E{g_{a_0}(X)}=a_0-\frac1\lambda+\frac2\lambda\e{-\lambda\frac{\ln(2)}{\lambda}}=a_0-\frac1\lambda+\frac2\lambda\frac12=a_0=\frac{\ln(2)}{\lambda} $$

$$ \E{g_{0}(X)}=0-\frac1\lambda+\frac2\lambda\e{-\lambda0}=\frac1\lambda=\frac{\ln(e)}{\lambda}>\frac{\ln(2)}{\lambda}=\E{g_{a_0}(X)} $$

Of course $\E{g_{0}(X)}=\frac1\lambda$ since $g_0(X)=X$

(5.32)

$$ \pr{X>2}=\int_2^\infty\edna{\frac12}{x}dx=-\e{-\frac12x}\eval2\infty=\e{-\frac12x}\eval\infty2=\e{-1}-0=\e{-1} $$

$$ \cp{X>10}{X>9}=\pr{X>1}=\int_1^\infty\edna{\frac12}{x}dx=-\e{-\frac12x}\eval1\infty=\e{-\frac12x}\eval\infty1=\e{-\frac12} $$

(5.33)

Let $t$ be the ungiven number of years that the used radio was in use. Then

$$ \cp{X>t+8}{X>t}=\pr{X>8}=\int_8^\infty\edna{\frac18}{x}dx=-\e{-\frac18x}\eval8\infty=\e{-\frac18x}\eval\infty8=\e{-1} $$

(5.34)

$$ \cp{X>10+20}{X>10}=\pr{X>20}=\int_{20}^\infty\edna{\frac1{20}}{x}dx=-\e{-\frac1{20}x}\eval{20}\infty=\e{-\frac1{20}x}\eval\infty{20}=\e{-1} $$

$$ \cp{X>10+20}{X>10}=\frac{\pr{X>10+20,X>10}}{\pr{X>10}} $$

$$ =\frac{\pr{X>10+20}}{\pr{X>10}} $$

$$ =\frac{\frac1{40}\int_{30}^{40}dx}{\frac1{40}\int_{10}^{40}dx}=\frac{x\eval{30}{40}}{x\eval{10}{40}}=\frac{10}{30}=\frac13 $$

(5.35)

Recall equation (5.4):

$$ F(t)=1-\e{-\int_0^t\lambda(t)dt} $$

For $b>a\geq40$, we have

$$ \cp{X>b}{X>a}=\frac{1-F(b)}{1-F(a)} $$

$$ =\frac{\e{-\int_0^{b}\lambda(t)dt}}{\e{-\int_0^{a}\lambda(t)dt}} $$

$$ =\e{\int_0^{a}\lambda(t)dt-\int_0^{b}\lambda(t)dt} $$

$$ =\e{-\bop\int_0^{b}\lambda(t)dt-\int_0^{a}\lambda(t)dt\bcp} $$

$$ =\e{-\int_{a}^{b}\lambda(t)dt} $$

$$ =\e{-\bosb.027(b-a)+\frac{.00025}3\bop(b−40)^3-(a-40)^3\bcp\bcsb} $$

where the last equation follows from

$$ \int_a^b\lambda(t)dt=\int_a^b(.027+.00025(t−40)^2)dt $$

$$ =.027\int_a^bdt+.00025\int_a^b(t − 40)^2dt $$

$$ \int(t − 40)^2dt=\int u^2du=\frac{u^3}3+C=\frac{(t-40)^3}3+C $$

$$ =.027(b-a)+.00025\frac{(t−40)^3}3\eval{a}{b} $$

$$ =.027(b-a)+.00025\Bop\frac{(b−40)^3}3-\frac{(a−40)^3}3\Bcp $$

$$ =.027(b-a)+\frac{.00025}3\Bop(b−40)^3-(a−40)^3\Bcp $$

In [910]: haz1=lambda a,b:exp(-(.027*(b-a)+(.00025/3)*(pw(b-40,3)-pw(a-40,3))))

In [911]: haz1(40,50)
Out[911]: 0.70234304000717884

In [912]: haz1(40,60)
Out[912]: 0.29919292885513166

(5.36)

We are given that, for $b>a\geq0$, we have

$$ \int_a^b\lambda(t)dt=\int_a^bt^3dt=\frac{t^4}4\eval{a}{b}=\frac{b^4}4-\frac{a^4}4 $$

Hence for $t>0$ we have

$$ F(t)=1-\e{-\int_0^t\lambda(x)dx}=1-\e{-\frac{t^4}4} $$

$$ \pr{X>2}=1-F(2)=1-\bop1-\e{-\frac{2^4}4}\bcp=\e{-4} $$

$$ \pr{0.4<X<1.4}=\pr{X<1.4}-\pr{X<0.4}=F(1.4)-F(0.4) $$

$$ =1-\e{-\frac{1.4^4}4}-\bop1-\e{-\frac{0.4^4}4}\bcp=\e{-\frac{0.4^4}4}-\e{-\frac{1.4^4}4} $$

In [915]: exp(-pw(0.4,4)/4)-exp(-pw(1.4,4)/4)
Out[915]: 0.61088067693107984

$$ \cp{X>2}{X>1}=\frac{\pr{X>2}}{\pr{X>1}}=\frac{\e{-4}}{\e{-\frac14}}=\e{-\frac{15}4} $$

(5.37)

Note that $g(x)=\norm{x}$ is not monotonic on $[-1,1]$. It switches directions at $x=0$. Hence we cannot use Theorem 7.1. We must compute the density of $Y=g(X)$ manually.

The density of $X$ is $f_X(x)=\frac1{1-(-1)}=\frac12$. So the distribution is $F_X(x)=\frac{x-(-1)}2=\frac{x+1}2$.

Sanity checks:

$$ \prB{X<0}=F(0)=\frac{0+1}2=\frac12 $$

$$ \prB{X<-\frac89}=F\Bop-\frac89\Bcp=\frac{-\frac89+1}2=\frac{\frac99-\frac89}2=\frac{\frac19}2=\frac1{18} $$

$$ \prB{X<\frac89}=F\Bop\frac89\Bcp=\frac{\frac89+1}2=\frac{\frac99+\frac89}2=\frac{\frac{17}9}2=\frac{17}{18} $$

$$ \prB{X<-\frac12}=F\Bop-\frac12\Bcp=\frac{-\frac12+1}2=\frac{\frac12}2=\frac14 $$

$$ \prB{X<\frac12}=F\Bop\frac12\Bcp=\frac{\frac12+1}2=\frac{\frac32}2=\frac34 $$

And the desired calc:

$$ \prB{\norm{X}>\frac12}=\prB{X<-\frac12\cup X>\frac12}=\prB{X<-\frac12}+\prB{X>\frac12} $$

$$ =\frac14+1-\prB{X<\frac12}=\frac54-\frac34=\frac12 $$

To find the density of $Y=\norm{X}$, we first find the distribution. For $y\in[0,1]$:

$$ F_Y(y)=\pr{Y<y}=\pr{\norm{X}<y}=\pr{-y<X<y}=F_X(y)-F_X(-y) $$

$$ =\frac{y+1}2-\frac{-y+1}2=\frac{y+1+y-1}2=\frac{2y}2=y $$

For $y<0, F(y)=0$ and for $y>1, F(y)=1$. That is

$$ F_Y(y)=\cases{0&y<0\\y&0\leq y\leq1\\1&1<y} $$

And check

$$ \prB{\norm{X}>\frac12}=\prB{Y>\frac12}=1-\prB{Y<\frac12}=1-F_Y\Bop\frac12\Bcp=\frac12 $$

$$ \prB{\norm{X}<\frac13}=\prB{Y<\frac13}=F_Y\Bop\frac13\Bcp=\frac13 $$

And to get the density of $Y$, we compute the derivative of the distribution:

$$ f_Y(y)=\wdervb{y}{F_Y(y)}=\cases{0&y<0\\1&0<y<1\\0&1<y} $$

Changing a finite number of points on the density won’t change anything. In particular, we need to set the density at the points where $F_Y$ is not differentiable. Set $f_Y(0)=0$ and $f_Y(1)=1$.

Hence $Y\uda01$.

(5.38)

$$ 4x^2+4xY+Y+2=0 $$

Let’s first solve for $x$ in terms of $Y\uda05$ using the quadratic formula:

$$ x=\frac{-b\pm\sqrt{b^2-4ac}}{2a} $$

where $a=4$, $b=4Y$, and $c=Y+2$. Then

$$ x=\frac{-4Y\pm\sqrt{(4Y)^2-4^2(Y+2)}}{8} $$

$$ =\frac{-4Y\pm\sqrt{4^2}\sqrt{Y^2-(Y+2)}}{8} $$

$$ =\frac{4\bop-Y\pm\sqrt{Y^2-Y-2}\bcp}{8} $$

$$ =\frac{-Y\pm\sqrt{Y^2-Y-2}}{2} $$

Then $x$ will be real IFF $Y^2-Y-2\geq0$:

$$ (Y-2)(Y+1)\geq0 $$

So $x$ is real if

  1. $Y=2$ or $Y=-1$
  2. $Y>2$ and $Y>-1$ $\iff$ $Y>2$
  3. $Y<2$ and $Y<-1$ $\iff$ $Y<-1$

So $x$ is real if

  1. $Y=2$ or $Y=-1$
  2. $Y>2$
  3. $Y<-1$

Since $Y$ is continuous, (1) is irrelevant since it only pertains to two points.

Since $f_Y(y)=\frac1{5-0}=\frac15$, $F_Y(y)=\frac{y-0}5=\frac{y}5$ for $y\in[0,5]$ and $F_Y(y)=0$ for $y<0$, we have

$$ \pr{Y>2}=1-F_Y(2)=1-\frac25=\frac35 $$

$$ \pr{Y<-1}=F_Y(-1)=0 $$

Hence

$$ \pr{X\in\wR}=\pr{Y>2}+\pr{Y<-1}=\frac35 $$

(5.39)

Note that $f_X(x)=\edn{x}=\e{-x}$.

Theormem 7.1 gives the following for a strictly increasing/decreasing function $Y=g(X)$:

$$ f_Y(y)=\cases{f_X(g^{-1}(y))\normB{\wderv{y}{g^{-1}(y)}}&y=g(x)\text{ for some }x\\0&y\neq g(x)\text{ for any }x} $$

Let $Y=g(X)=\ln(X)$. Then $g$ is strictly increasing on $[0,\infty)$. And since the log function is unbounded above and below, for every $y\in\wR$ there exists some $x\in[0,\infty)$ such that $y=g(x)$. Then $g^{-1}(y)=e^y$ and

$$ f_Y(y)=f_X(e^y)\normB{\wderv{y}{e^y}}=\e{-e^y}e^y=\e{y-e^y} $$

Or we can compute the density of $Y$ manually. First we compute the distribution of $Y$. For some $y\in\wR$ we have

$$ F_Y(y)=\pr{Y<y}=\pr{\ln(X)<y}=\pr{X<\e{y}}=F_X(e^y)=1-\e{-e^y} $$

Hence

$$ f_Y(y)=\wdervb{y}{F_Y(y)}=\wdervb{y}{1-\e{-e^y}}=-\e{-e^y}\bop-e^y\bcp=\e{y-e^y} $$

Or

$$ f_Y(y)=\wdervb{y}{F_Y(y)}=\wdervb{y}{F_X(e^y)}=f_X(e^y)\wderv{y}{e^y}=\e{-e^y}e^y=\e{y-e^y} $$

Check

$$ F_Y(\infty)=1-\e{-e^\infty}=1-\e{-\infty}=1 $$

Or

$$ F_Y(\infty)=\int_{-\infty}^{\infty}\e{y-e^y}dy $$

$$ u=e^y\dq du=e^ydy $$

$$ \int\e{y-e^y}dy=\int\e{-u}du $$

$$ v=-u\dq dv=-du $$

$$ \int\e{y-e^y}dy=\int\e{-u}du=-\int\e{v}dv=-e^v=-\e{-u}=-\e{-e^y} $$

$$ F_Y(\infty)=\int_{-\infty}^{\infty}\e{y-e^y}dy=\e{-e^y}\eval{\infty}{-\infty}=\e{-\e{-\infty}}-\e{-\e{\infty}}=\e{-0}-\e{-\infty}=1 $$

(5.40)

Note that

$$ f_X(x)=\cases{0&x<0\\1&0\leq x\leq1\\0&1<x} $$

$$ F_X(x)=\cases{0&x<0\\x&0\leq x\leq1\\1&1<x} $$

Let $Y=g(X)=\e{X}$. Then $g$ is strictly increasing on $\wR$. Since $g:\wR\mapsto(0,\infty)$, for every $y>0$ there exists some $x\in\wR$ such that $y=g(x)$ and $g^{-1}(y)=\ln(y)$. But for $y\leq0$, there’s no $x\in\wR$ such that $y=g(x)$. Hence Theorem 7.1 gives

$$ f_Y(y)=\cases{0&y\leq0\\0&0<y=e^x<1,x<0\\\frac1y&1\leq y=e^x\leq e,0\leq x\leq1\\0&e<y=e^x,1<x} $$

Or we can compute the distribution and density manually:

$$ F_Y(y)=\pr{Y<y}=\pr{\e{X}<y}=\pr{X<\ln(y)}=F_X(\ln(y))=\cases{0&\ln(y)<0\\\ln(y)&0\leq\ln(y)\leq1\\1&1<\ln(y)} $$

Hence

$$ F_Y(y)=\cases{0&y<1\\\ln(y)&1\leq y\leq e\\1&e<y} $$

And

$$ f_Y(y)=\wdervb{y}{(F_Y(y)}=\cases{0&y<1\\\frac1y&1\leq y\leq e\\0&e<y} $$

Check

$$ F_Y(\infty)=\int_1^e\frac{dy}y=\ln(e)-\ln(1)=1-0=1 $$

(5.41)

$\theta\uda{-\frac\pi2}{\frac\pi2}$ so that $f_\theta(x)=\frac1{\frac\pi2-(-\frac\pi2)}=\frac1\pi$ and $F_\theta(x)=\frac{x-(-\frac\pi2)}{\pi}=\frac{x+\frac\pi2}\pi=\frac{x}\pi+\frac12$. Hence

$$ F_R(r)=\pr{R<r}=\pr{A\sin(\theta)<r}=\prB{\sin(\theta)<\frac{r}A}=\prB{\theta<\sin^{-1}\Bop\frac{r}A\Bcp} $$

$$ =F_\theta\Bocb\sin^{-1}\Bop\frac{r}A\Bcp\Bccb=\frac{\sin^{-1}\bop\frac{r}A\bcp}\pi+\frac12 $$

And the density of $R$ is

$$ f_R(r)=\wdervb{r}{F_R(r)}=\wdervBcb{r}{\frac1\pi\sin^{-1}\Bop\frac{r}A\Bcp+\frac12} $$

$$ =\frac1\pi\wdervBcb{r}{\sin^{-1}\Bop\frac{r}A\Bcp} $$

$$ =\frac1{A\pi}\frac1{\sqrt{1-\bop\frac{r}A\bcp^2}} $$