Problem 1

say the random variable X has \(f(x)=c(1+x)\) for \(x=1,2,..,N\), \(N>1\) fixed and known. Find E[X].

The following routine generates data from this random variable. Use it to verify your calculations for N=2 and N=5.

rhw5p1 <- function(n=1e5, N=2) {
  sample(1:N, size=n, replace = TRUE, prob=1:N+1)
}

Problem 2

say the random vector \((X,Y)\) has \(f(x,y) = c \cdot (x+y^2)\) for \(0<x<y<1\), o otherwise.

  1. Find Cov(X,Y).

  2. Find E[X|Y=y]

  3. Let \(Z=XY\). Find the density of Z.

The following routine generates data from f:

rhw5p2 <- function(n=1e4) {
  f<-function(x) (x[1]+x[2]^2)*ifelse(x[1]<x[2],1,0)
  xy<-matrix(0,n,2)
  for(i in 1:n) {
     repeat {
       u <- runif(2)
       if(runif(1)<f(u)/2) {xy[i, ]<-u;break}
     }
  }
  xy
}

use this to do simulations to verify your answers.

Problem 3

Let \(X\sim Ber(0.5)\) and \(Y|X=x \sim Ber(\frac1{1+x})\). Let \(U=XY\). Find \(Var(U)\) using

  1. simulation
  2. the approximation of Var[h(X,Y)]
  3. analytic calculation

Problem 4

Let \(X_i;i=1,..\) be a sequence of independent and identically distributed random variables with \(\mu=E[X_1]\) and \(\sigma^2=Var[X_1]<\infty.\). Let \(Z_n=\frac{\sum_{i=1}^n X_i-n\mu}{\sqrt{n}\sigma}\), then according to the central limit theorem \(Z_n\) converges in distribution to a standard normal random variable. So we would expect \(P(Z_n\le x)\approx \Phi(x)\), where \(\Phi\) is the cdf of a standard normal. But how large does n have to be? Let’s look at an example:

Say \(X_1\sim Ber(p)\). Find N such that for any n>N

\[\lvert P(Z_n\le x)-\Phi(x)\rvert<0.01\]

and

  1. p=0.5, x=0.3
  2. p=0.1, x=0.3