本次英国代写主要为统计相关的限时测试

A12 Simulation And Statistical Programming

1.令p(x)为截断的高斯随机变量的密度
p(x)/ e
(x)2
2 2 1倍
其中2 R; 2> 0和2 R是参数。
(a)[10分]
(i)(工作簿-4)编写一个伪代码算法,用于使用pdf p模拟X
反转方法(您可以假设您可以访问函数(x)=
P(Z x)z其中Z为标准正态变量,其反数为1)。
答:
步骤1模拟u U [0; 1]。
步骤2
P(X x)= P(N(;)xjX)
= P(N(;)2 [; x] = P(X)
=
H
((x)=)(()=)
一世
=(1(()=))
因此
z = F 1
X(u)= + 1
</ s> </ s> </ s> </ s> </ s> </ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s> </ s>
+你
</ s> </ s> </ s> </ s> </ s>
1个
</ s> </ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s> </ s>
有正确的分配。
(ii)假设我们要使用提案g用pdf f模拟变量X。描述
拒绝采样算法,说明f和g必须满足哪些假设
并给出算法效率的表达式(
必须模拟变量Y g以获得X f)的一个样本,您必须
证明合法。
ANS(B-3):关于f的条件; g是必须存在M使得f = g M.
步骤1:模拟Y g和U U [0; 1]。步骤2:如果MU f
g(Y)接受并返回
X = Y否则转到1。 P(接受)= 1 = M。因此平均试验次数为M。
(iii)假设我们模拟Y1; Y2; :::i.i.d.带有定律N(; 2)的随机变量直到
生成的数字大于。解释布里
y为什么这是拒绝
p的采样算法,并计算每次模拟的平均试验次数。
Ans(S-3):
这里我们有e p(x)= e
2 2 1x和p(x)=(2 2)1 = 2e p(x)= Zp
Zp =(
</ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s>
)= P(Z
</ s> </ s> </ s> </ s> </ s>

其中Z是标准高斯。因此,p = q 1 = Zp和平均试验次数

1 =(
</ s> </ s> </ s> </ s> </ s>
</ s> </ s> </ s> </ s> </ s>

显然,MU p
q(Y),Y。
(b)[15分]我们自此假设= 0,因此
p(x)/ e
2倍
2 2 1倍
令q(x)为参数> 0的转换后指数变量的密度
q(x)= q(xj;)= exp((x))1x:
(i)计算最小上限M
p(x)
q(x)
M; x:
提示:您可以区分大小写和<。
回答(S / N-3):如果>
exp((z))exp(z2
= 2)exp(2
= 2)
如果
exp((z))exp(z2
= 2)exp(2
= 2)
所以
M =
8
<

p2 [1()]
exp(2 = 2)如果
p2 [1()]
exp(2 = 2)else
(ii)使用提案为p的拒绝采样算法编写伪代码
分布q在可能的情况下进行适当的简化。 (你可以
假设您可以直接生成均值1的指数随机变量)。
ANS(B-2):步骤1:通过z = + Z1 =生成z Exp(;),其中Z1是a
指一个指数。步骤2:如果>和,则计算(z)= exp((z)2 = 2)
(z)= exp(()2 = 2)exp((z)2 = 2)否则。步骤3;接受u(z):
否则转到1。
(iii)上述算法被接受的概率是多少?
Ans(S / N-3):案例。取z Exp(;)
E [(z)] = E [expf(z)
2个
= 2g]
=
11
0
e(()u)2 = 2
乌杜
=
11
0
e(u +)2 = 2
1号
2 [()2 2]

= exp(2
= 2)
11
0
e(u +)2 = 2

= exp(2
= 2)()
p
2:
情况<。
E [(z)] = exp(()
2个
= 2)E [expf(z)
2个
= 2g]
= exp(2
= 2)()
p
2:

1. Let p(x) be the density of a truncated Gaussian random variable
p(x) / e
(x )2
22 1x
where  2 R; 2 > 0 and 2 R are parameters.
(a) [10 marks]
(i) (bookwork – 4) Write a pseudocode algorithme for simulating X with pdf p using
the inversion method (you can assume that you have access to the function (x) =
P(Z  x) zhere Z is a standard normal variable and its inverse  1).
Ans:
Step 1 Simulate u  U[0;1].
Step 2 Since
P(X  x) = P(N(; )  xjX  )
= P(N(; ) 2 [ ; x]=P(X  )
=
h
((x )=) (( )=)
i
=(1 (( )=))
Thus
z = F 1
X (u) =  +  1


 


+ u

1 
 


has the right distribution.
(ii) Suppose we want to simulate a variable X with pdf f using a proposal g. Describe
the rejection-sampling algorithm stating what assumptions f and g must satisfy
and give an expression for the eciency of the algorithm (the mean number of
variables Y  g one must simulate to get one sample of X  f) which you must
justify.
ANS (B – 3): The condition on f; g is that there must exists M such that f=g  M.
Step 1: Simulate Y  g and U  U[0;1]. Step 2: If MU  f
g (Y ) accept and return
X = Y . Otherwise goto1. P(accept) = 1=M. so mean number of trials is M.
(iii) Suppose that we simulate Y1; Y2; : : : i.i.d. random variables with law N(; 2) until
the generated number is larger than . Explain brie
y why this is a rejection
sampling algorithm for p and calculate the average number of trials per simulation.
Ans (S – 3):
Here we have that e p(x) = e
22 1x and p(x) = (22) 1=2e p(x)=Zp with
Zp = (


) = P(Z  

)
where Z is a standard Gaussian. Thus, p=q  1=Zp and the mean number of trials
is
1=(


)
Clearly, MU  p
q (Y ) , Y  .
(b) [15 marks] We henceforth assume that  = 0 so that
p(x) / e
x2
22 1x
Let q(x) be the density of a translated exponential variable with parameter  > 0
q(x) = q(xj; ) =  exp( (x ))1x :
(i) Calculate the least upper bound M such that
p(x)
q(x)
 M; x  :
Hint: you may distinguish the cases   and < .
Ans (S/N – 3) : if  >
exp((z )) exp( z2
=2)  exp(2
=2  )
if  
exp((z )) exp( z2
=2)  exp( 2
=2)
so
M =
8
<
:
 p2[1 ( )]
exp( 2=2 ) if  
 p2[1 ( )]
exp( 2=2) else
(ii) Write the pseudocode for a rejection sampling algorithm for p using the proposal
distribution q making the appropriate simpli cations when possible. (you may
assume that you can directly generate a mean 1 exponential random variable).
ANS (B – 2): Step1: generate z  Exp(; ) by z = + Z1= where Z1 is a
mean one exponential. Step 2 : compute (z) = exp( ( z)2=2) if  > and
(z) = exp( ( )2=2) exp( ( z)2=2) otherwise. Step 3 ; Accept if u  (z):
Otherwise goto1.
(iii)What is the probability of acceptance in the above algoithm?
Ans (S/N – 3) : case   . Take z  Exp(; )
E[(z)] = E[expf ( z)
2
=2g]
=
Z 1
0
e (( ) u)2=2
e udu
= 
Z 1
0
e (u+ )2=2
e 1
2 [( )2 2]
du
=  exp( 2
=2)
Z 1
0
e (u+ )2=2
du
=  exp( 2
=2)( )
p
2:
case  < .
E[(z)] = exp(( )
2
=2)E[expf ( z)
2
=2g]
=  exp( 2
=2)( )
p
2: