STA510 Statistical modelling and simulation
Mandatory assignment 2

11
-1
11
-1
1D（x，y）dxdy（1）

1D（x，y）=（

2 + y
2≤1

θCMC=
4
ñ
Xn
i = 1
1D（西
，Yi），（2）

a）争论为什么（2）是积分（1）的蒙特卡洛估计量。

，Yi）具有成功概率为π/ 4的伯努利分布。
b）Pn做哪个分布
i = 1 1D（西
，易）有吗？

c）R对n = 1000实施R中的蒙特卡洛估计（2）。获得许多独立的
π的估计。

d）R找到n = 1000的（2）正确估计π到第二个小数的概率
（即，估算值以“ 3.14”开头）。
e）根据您对蒙特卡洛中被积和对数变量的了解

a + b − Xi = −Xi
，Wi = -Yi）将减少蒙特卡洛方差。为什么或者为什么不？
f）R通过仿真验证您从e）点得出的结论是正确的。

shift（u）=（
-1 + u如果0≤u≤1，

（3）

shift <-function（u）{return（（（（u + 2.0）%% 2.0）-1.0）}
g）R使用对数变量（Xi
，Vi = shift（Xi））和（Yi
，Wi = shift（Yi））。

2
，即Xi〜N（0，σ2
），Yi〜N（0，σ2
），所以

f（x，y）= 1
2πσ2

X
2

2
</ s> </ s> </ s>

ÿ
2

2
</ s> </ s> </ s>
h）R使用独立的正常建议实施（1）的重要性抽样程序
f（x，y）以上。

Problem 2:
In this problem, imagine that you work for an insurance company. Further, you are responsible
for setting aside enough capital to, with high probability, be able to fulfill claims originating from
storm damage.
You are modeling the number of storms as non-homogenous Poisson process, with intensity
λ(t) = 297 (1 + cos (2π (t + 1/10))) (1 − exp(−t/10)/2)
10
+ 3/5 (4)
where time t is measured in years since Jan 1st 2020 (i.e. t = 0 correspond to Jan 1st 2020,
t = 1.5 is July 1st 2021 and so on)1
. As can be seen from the specification of λ(t), there is a
strong seasonal effect, and also the winter intensity is increasing due to climate change.
In the following point, you may find the R-function integrate useful.
a)R Let X be the number of storms in the year 2020 (i.e. t ∈ [0, 1)). Which distribution does
X have?
What is the expected number of storms in 2025 (i.e. t ∈ [5, 6))?
What is the expectation and standard deviation of the total number of storms in 2020 and
2021 combined.
b) Find the smallest possible λmax so that λmax ≥ λ(t) for all t ≥ 0.
c)R Write a function that simulates the times storms occur in some time interval [a, b] where
a ≥ 0.0 and b > a.
Check your algorithm by replicating the expectations and standard deviation in point a)
using simulations.
Now assume that the size of total claims2
in million Norwegian kroner, from any given storm has
an exponential distribution with mean c(t), where
c(t) = 10 exp 
5t
100
(5)
Here, t is the time the storm occurred (also in years after Jan 1st 2020). It is seen that the size
of the claims increases, which reflect both economic growth and that insurance company expects
to grow in the future.
d)R Based the function written in point c) above, write a function that simulates the total claim
size resulting from all storms in some given time interval [a, b].
Find the mean and standard deviation of the claim size resulting from storms in the year
2020.
Find a confidence 95% interval for the mean.
How much funds must the insurance company set aside to be 97.5% certain to be able to
cover the total claim size of the year 2020?
Suppose you wish to improve the estimate of the mean of the total claim size. A common technique
for reducing variance in Monte Carlo integration, Rao-Blackwelliztion, may be though of as a way
to exploit the law of total expectation3
to reduce the variance. In the present case, this would
amount to exploiting that we know the expectation of sums of exponentially distributed random
variables. Suppose X is the total claim size originating in time span [a, b], and N is the number
of storms occurring in the time span [a, b]. Then X may be written as
X =
(PN
i=1 c(ti)εi
if N > 0
0 if N = 0
where ti
, i = 1, . . . , N are the times the storms occur and the εis iid exponentially distributed
with mean 1. Then the expectation of X may be written as
E(X) = E(E(X|N, t1, . . . , tN )) = E (Y ) (6)
where
E(X|N, t1, . . . , tN ) = Y =
(PN
i=1 c(ti) if N > 0
0 if N = 0
(7)
e)R Use (6,7) to implement another Monte Carlo estimator for E(X).
Compare this Monte Carlo estimator to the one obtained in point d) for the year 2020.
f)R More difficult: Based on the law of total variance V ar(X) = E(V ar(X|N, t1, . . . , tN )) +
V ar(E(X|N, t1, . . . , tn)), propose and implement an improved estimator for the variance of
X. Compare this estimator to the one in point d) (where you simply simulate X) for the
year 2020