Stoch Proc - Lab/Tutorial 5 Solutions

Scott Alexander

Q1

(a)

(* crude estimate *)
n=100000;
rv=RandomReal[UniformDistribution[{1,8}],n];
g[x_]:=21x (E^(-x/2));
grv=g[rv];
mu1=Mean[grv];
sd1=StandardDeviation[grv]/(Sqrt[n]);
z975=InverseCDF[NormalDistribution[],0.975];
lb1=mu1-sd1*z975;
ub1=mu1+sd1*z975;
{mu1,sd1}
{lb1,ub1}

(* control variate estimate *)
QQ=(∫_1^8)(Sqrt[x])(1/7)\[DifferentialD]x;
q[x_]:=(Sqrt[x]);
qrv=q[rv];
a=Covariance[grv,qrv]/Variance[qrv];
grvTilde=grv-a(qrv-QQ);
mu2=Mean[grvTilde];
sd2=StandardDeviation[grvTilde]/(Sqrt[n]);
lb2=mu2-sd2*z975;
ub2=mu2+sd2*z975;
{mu2,sd2}
{lb2,ub2}

(b)

(* antithetic variate estimate *)
XX=(∫_1^8)x(1/7)\[DifferentialD]x;
hrv=g[2*XX-rv];
grvHat=((grv+hrv)/2);
mu3=Mean[grvHat];
sd3=StandardDeviation[grvHat]/(Sqrt[n]);
lb3=mu3-sd3*z975;
ub3=mu3+sd3*z975;
{mu3,sd3}
{lb3,ub3}

(c)

To show same distribution it suffices to show same characteristic function.

The CF of    X    which is
𝔼[(e^(i u X))] = (∫_(-∞)^∞)(e^(i u x))(Subscript[f, X])(x)dx
  = (∫_1^8)(e^(i u x))(1/7)dx = ...

The CF of    2𝔼[X]-X    is
𝔼[(e^(i u (2𝔼[X]-X)))] = ...

(∫_1^8)(E^(I u x))(1/7)\[DifferentialD]x//Expand

(E^(I u 9))((∫_1^8)(E^(-I u x))(1/7)\[DifferentialD]x)//Expand

Q2

(a)

Step 1.
Find distribution function
(Subscript[F, X])(x) = (∫_(-∞)^x)(Subscript[f, X])(u)du =(∫_0^x)(24/(((3u+2))^3))du = 1-(4/(((2+3 x))^2)).

Step 2.
Find inverse distribution function
(Subscript[F, X]^(-1))(u) = x
by solving
u = F(x)
for x.

Proceeding we have
u = F(x) = 1-(4/(((2+3 x))^2)) = 1-(4/(4+12x+9(x^2))) = ((12x+9(x^2))/(4+12x+9(x^2)))
so
4u+12u x+9u (x^2)  = 12x+9(x^2)
or
9(x^2)(u-1)+12(u-1)x+4u = 0
with solution
x = (Subscript[F, X]^(-1))(u) = ...

Step 3.
Generate U(0,1) RVs and pass to (Subscript[F, X]^(-1)).

Assuming[{x≥0},(∫_0^x)(24/(((3u+2))^3))\[DifferentialD]u]

Solve[Assuming[{x≥0},(∫_0^x)(24/(((3u+2))^3))\[DifferentialD]u]==u,x]

Plot[((2 (1-(Sqrt[1-u])-u))/(3 (-1+u))),{u,0,1}]

n=100000;
rvU=RandomReal[UniformDistribution[],n];
rvX=((2 (1-(Sqrt[1-rvU])-rvU))/(3 (-1+rvU)));
p1=Histogram[rvX,Automatic,"PDF"];
p2=Plot[(24/(((3x+2))^3)),{x,0,2}];
Show[p1,p2]

(b)

Q3

(a)

We have is Gaussian with
𝔼[(Subscript[X, t])] = -(t^2)
and
Q(s,t) = cov((Subscript[X, s]),(Subscript[X, t]))=(e^(-4|t-s|))cos((π/2)|t-s|)).

Plot[Exp[-4Abs[u]]Cos[π Abs[u]/2],{u,-2,2},PlotRange->All]

(b)

Use TNC Part 3.

(c)

Use TNC Part 4.