Problem 1

Say \((X,Y)\) is a discrete rv with joint pdf \(f_{X,Y}(x,y)=(1-p)^2p^x; x,y \in \{0,1,..\}, y \le x, 0<p<1\). Let \(U=I(|X-Y|\le 1)\). Find the density of U.

\[ \begin{aligned} &P(U=1) = P(|X-Y|\le 1) = \\ &P(X=Y\text{ or } X=Y+1) = \\ &P(X=Y)+ P(X=Y+1) \text{ \{because }x\le y\} = \\ &\sum_{k=0}^\infty P(X=Y,X=k)+\sum_{k=0}^\infty P(X=Y+1,X=k)=\\ &\sum_{k=0}^\infty P(X=k,Y=k)+\sum_{k=1}^\infty P(X=k,Y=k-1)=\\ &\sum_{k=0}^\infty(1-p)^2p^k+\sum_{k=1}^\infty(1-p)^2p^k=\\ &2\sum_{k=0}^\infty(1-p)^2p^k - (1-p)^2 = \\ &2(1-p)-(1-p)^2=(2-(1-p))(1-p)=\\ &(1+p)(1-p)=1-p^2\\ &P(U=0)=p^2 \end{aligned} \]

Problem 2

Let \(X\sim U[-1,1]\).

  1. say \(Y=1-X^2\). Find the density of \(Y\).

\(-1<x<1\), so \(0<x^2<1\), so \(0<1-x^2<1\). Let \(0<y<1\), then

\[ \begin{aligned} &F_Y(y)=P(Y<y) = P(1-X^2<y)= P(X^2>1-y) = \\ &1-P(X^2<1-y) = \\ &1-P(\sqrt{1-y}<X<\sqrt{1-y}) = \\ &1-\sqrt{1-y}\\ &f_Y(y)=\frac{1}{2\sqrt{1-y}} \end{aligned} \]

n=1e4
y=1-runif(n,-1, 1)^2
hist(y, 100, freq=FALSE,main="")
curve(1/2/sqrt(1-x), 0, 1, add=TRUE, col="blue",lwd=2)

  1. say \(Y=1-\left(2x-\frac{x}{|x|}\right)^2\). Find the density of Y.

Here is a graph of this function:

curve(1-(2*x-x/abs(x))^2, -1,1, n=1000,ylab="")

so again \(0<y<1\), and then

\[y= 1-(2x\pm 1)^2 \rightarrow x=\frac12\left(\pm1\pm\sqrt{1-y}\right)\]

curve(1-(2*x-x/abs(x))^2, -1,1, n=1000,ylab="")
y=0.5
abline(h=y,col="red")
abline(v=(1+c(-1,1)*sqrt(1-y))/2,col="red")
abline(v=(-1+c(-1,1)*sqrt(1-y))/2,col="red")

and so

\[ \begin{aligned} &F_Y(y) =P\left( \frac12(-1-\sqrt{1-y})<X<\frac12(-1+\sqrt{1-y})\right)+ \\ &P\left( \frac12(1-\sqrt{1-y})<X<\frac12(1+\sqrt{1-y})\right) = \\ &\left(\frac12(-1+\sqrt{1-y}) -\frac12(-1-\sqrt{1-y})\right)/2 + \\ &\left(\frac12(1+\sqrt{1-y})-\frac12(1-\sqrt{1-y})\right)/2 = \\ &\sqrt{1-y}\\ &f_Y(y)=\frac1{2\sqrt{1-y}} \end{aligned} \]

n=1e4
u=runif(n,-1,1)
y=ifelse(u<0, 1-(2*u+1)^2, 1-(2*u-1)^2)
hist(y, 100, freq=FALSE,main="")
curve(1/2/sqrt(1-x), 0, 1, add=TRUE, col="blue",lwd=2)

Problem 3

Say the random vector \((X,Y)\) has joint density \(f(x,y)=\frac1{2\pi}\exp\{-(x^2+y^2)/2\}\). Let \(D=\sqrt{X^2+Y^2}\). Find the density of D.

First notice that \(X\perp Y\) and \(f_X(x)=f_Y(x)=\frac1{\sqrt{2\pi}}e^{-x^2/2}\). Therefore

\[ \begin{aligned} &F_{X^2}(x) =P(X^2<x)=\\ &P(-\sqrt{x}<X<\sqrt{x}) = \\ &\int_{-\sqrt{x}}^{\sqrt{x}}\frac1{\sqrt{2\pi}}e^{-t^2/2} \\ & \\ &f_{X^2}(x) = \frac1{\sqrt{2\pi}}e^{-(\sqrt{x})^2/2}\frac1{2\sqrt{x}}-\frac1{\sqrt{2\pi}}e^{-(-\sqrt{x})^2/2}\frac{-1}{2\sqrt{x}}=\\ &\frac1{\sqrt{2\pi x}}e^{-x/2} \end{aligned} \] \(X\perp Y\), so also \(X^2\perp Y^2\), and so by the convolution formula we find

\[ \begin{aligned} &f_{X^2+Y^2}(x) = \int_{-\infty}^{\infty} f_{X^2}(t)f_{Y^2}(x-t)dt= \\ & \int_{0}^{x}\frac1{\sqrt{2\pi t}}e^{-x/2}\frac1{\sqrt{2\pi (t-x)}}e^{-(x-t)/2}dt = \\ &\frac1{2\pi}e^{-x/2} \int_{0}^{x}\frac1{\sqrt{t(x-t)}}dt = \\ &\frac1{2\pi}e^{-x/2} \int_{0}^{x}\frac{1}{\sqrt{(t/x)(1-t/x)}}(dt/x) = \\ &\frac1{2\pi}e^{-x/2} \int_{0}^{1}\frac{1}{\sqrt{z(1-z)}}dz = \\ &\frac1{2}e^{-x/2} \end{aligned} \]

so we find \(D^2\sim Exp(1/2)\). Finally

\[ \begin{aligned} &P(D<d) = P(D^2<d^2) = \\ &\int_0^{d^2} \frac1{2}e^{-x/2}dx = \\ &-e^{-x/2}|_0^{d^2} =1-e^{-d^2/2} \\ &f_D(d)=e^{-d^2/2}d \end{aligned} \]

n=1e4
D=sqrt(rnorm(n)^2+rnorm(n)^2)
hist(D, 100, freq=FALSE,main="")
curve(x*exp(-x^2/2), 0, 15, add=TRUE, col="blue",lwd=2)

Problem 4

Let \(X,Y\) be independent rv’s with \(P(X=k)=P(Y=k)=\frac1N\), \(k=1,...,N; N\ge 2\). Let \(M=\min\{X,Y\}\). Find the density of M.

\[ \begin{aligned} &P(M>m) =P(X>m,Y>m)= \\ &P(X>m)P(Y>m) = \\ &\left[1-P(X\le m)\right]^2 = \\ &\left[1-\frac{m}{N}\right]^2\\ &\left[\frac{N-m}{N}\right]^2\\ &\\ &f_M(1)=P(M=1)=\\ &P(X>0)-P(X>1)=\\ &1-\frac{(N-1)^2}{N^2}=\frac{2N-1}{N^2}\\ &\\ &m=2,...,N-1\\ &f_M(m)=P(M=m)=\\ &P(X>m-1)-P(X>m)=\\ &\frac{(N-m+1)^2}{N^2}-\frac{(N-m)^2}{N^2}=\\ &\frac{2(N-m)+1}{N^2}\\ &\\ &f_M(N)=P(M=N)=\\ &P(X>N-1)-P(X>N)=\\ &\frac{(N-(N-1))^2}{N^2}=\frac{1}{N^2} \end{aligned} \]

f=function(N) {
  n=1e4
  xy=matrix(sample(1:N,size=2*n,replace=TRUE), ncol=2)
  M=apply(xy, 1, min)
  S=table(M)/n
  K=c(2*N-1, 2*(N-2:(N-1))+1, 1)/N^2
  rbind(S, K)
}
f(3)
##           1         2         3
## S 0.5536000 0.3297000 0.1167000
## K 0.5555556 0.3333333 0.1111111
f(5)
##        1      2      3      4      5
## S 0.3591 0.2752 0.2007 0.1225 0.0425
## K 0.3600 0.2800 0.2000 0.1200 0.0400
f(7)
##           1         2         3         4         5          6          7
## S 0.2666000 0.2253000 0.1822000 0.1425000 0.1007000 0.06240000 0.02030000
## K 0.2653061 0.2244898 0.1836735 0.1428571 0.1020408 0.06122449 0.02040816