Problem3_8 - nsim = 100000; M = 7.456449; randvars = ;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem 3.8 STA 6934 Damaris Santana-Morant 1. g 1 ( x ) = 1 2 e -| x | M = sup y e - y [sin( y )] 2 1 2 e -| y | = sup y 2[sin( y )] 2 e - y + | y | . Since y < | y | for y > 1, - y + | y | > 0 for y > 1. Thus e - y + | y | → ∞ as y → ∞ and M = . Thus AR no longer apply, an alternative MCMC methods. 2. g 2 ( x ) = 1 2 2 sech 2 ( x 2 ) M = sup y e - y [sin( y )] 2 1 2 2 sech 2 ( y 2 ) = sup y 2 2[sin( y )] 2 e - y e y 2 + e - y 2 4 < sup y 2[sin( y )] 2 e - y e y 2 Since y < y 2 for y > 2, - y + x 2 > 0 for y > 2. Thus e - y +( y/ 2) → ∞ as y → ∞ and M = . Thus AR no longer apply, an alternative MCMC methods. 3. g 3 ( x ) = 1 2 π 1 1+ x 2 / 4 M = sup y e - y [sin( y )] 2 1 2 π 1 1+ y 2 / 4 = 7 . 456449 . It occurs at y = 14 . 14 (Figure 1). For one simulation the mean was 6.4835 and the histogram is shown in Figure 2. The Matlab code for the Accept Reject Algorithm is the following: 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
%This program will generate nsim random variables from %the density f(x)=exp{-sqrt(x)}*[sin(x)]^2 using the %Accept Reject Algorithm with candidate density Cauchy(0,2).
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: nsim = 100000; M = 7.456449; randvars = ; %vector of simulated random variables i = 0; while (i &lt;= nsim) u_1 = rand(1,1); u_2 = rand(1,1); Y = 2*tan((u_2-1/2)*pi); %generate Cauchy(0,2) if (Y &gt; 0) %consider Cauchy variables such that 0&lt;Y&lt;\infty temp = (1/M)*(exp(-sqrt(Y))*[sin(Y)]^2)/(1/(2*pi*(1+Y^2/4))); if (u_1 &lt; temp) randvars = [randvars;Y]; i = i + 1; end end end 4. g 4 ( x ) = 1 2 e-x 2 2 (Corrected by George Casella) M = sup y e- y [sin( y )] 2 1 2 e-y 2 2 = sup y 2 [sin( y )] 2 e- y + y 2 / 2 . Since y &lt; y 2 2 for y &gt; 4 1 / 3 ,- y + y 2 2 &gt; 0 for y &gt; 4 1 / 3 . Thus e- y + y 2 / 2 as y and M = . Thus AR no longer apply. 2...
View Full Document

Page1 / 2

Problem3_8 - nsim = 100000; M = 7.456449; randvars = ;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online