Professional Documents
Culture Documents
Week2 Handout
Week2 Handout
Week2 Handout
1–3
L.E. Meester
Week 2
1/ 35
Standard errors Computer simulation §§15.1–3
3/ 35
Standard errors Computer simulation §§15.1–3 Canonical Monte Carlo Standard errors
Recall:
I.i.d. sequence (of random variables)
A sequence X1 , X2 , . . . of random variables is called independent
and identically distributed (or iid) if
all Xi have the same distribution;
the collection X1 , . . . , Xn is independent, for any n.
4/ 35
Standard errors Computer simulation §§15.1–3 Canonical Monte Carlo Standard errors
Known rules:
Variance of iid sums and averages
If X1 , . . . , Xn are iid with E [X1 ] = µ and Var(X1 ) = σ 2 . Then
σ2
2 X1 + · · · + Xn
Var(X1 + · · · + Xn ) = nσ and Var = .
n n
√
The average we denote by X̄n , so SD(X̄n ) = σ/ n.
5/ 35
Standard errors Computer simulation §§15.1–3 Canonical Monte Carlo Standard errors
6/ 35
Standard errors Computer simulation §§15.1–3 Canonical Monte Carlo Standard errors
σ̂
s.e.(X̄n ) ≈ √ .
n
7/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
8/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
10/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
11/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
Period length:
Longer is better.
It can be no longer than the number of elements of E .
Reproducibility: same seed always produces the same
numbers.
Speed:
Functions like log, exp, sin take 5–10 as much time as a single
RNG-call (so it says in Asmussen and Glynn somewhere).
Presently, no reason to sacrifice quality for greater speed.
Portability: identical behavior of PRNG on different platforms.
How to judge “randomness”:
theoretical properties are used to narrow down the search for
good candidates;
then statistical tests are used to make final selection(s).
12/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
13/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
14/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
15/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
16/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
Reproducibility
rand(’state’,100);
randn(’state’,100);
u=rand(10,1);
z=randn(10,1);
Table41=[u,z]
17/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
18/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
19/ 35
Standard errors Computer simulation §§15.1–3 Simulation: for real? PRNGs Checking randomness
Have we checked:
The distribution? A bit: one-dimensional marginal
Independence? Not at all
Both figures illustrate the LLN: the histogram converges to the
true density. We could try to answer the question: Does the
wiggliness in these plots agree with what follows from the CLT?
How: by computing a standard error for the plotted numbers
and comparing that to what we see.
23/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
24/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
25/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
26/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
27/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
N.B.: Figures 15.1 and 15.2 are to show the effect of the sample
size. In practice you naturally do only one simulation.
28/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
29/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
30/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
31/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
33/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
34/ 35
Standard errors Computer simulation §§15.1–3 Accuracy of bM Pricing options Vectorization
Examples
EurCall4.m improves over EurCall3.m because now one
statement generates a vector of M replications of S(T ):
Sfinal =
Snul*exp((r-0.5*sigma^2)*T+sigma*sqrt(T)*randn(M,1));
In HigF71.m one statement generates a whole price path; in
HigF73.m even several of them using Matlab’s cumprod:
tvals = [0:dt:T];
Svals = S*cumprod(exp((mu-0.5*sigma^2)*dt
+ sigma*sqrt(dt)*randn(M,L)),2);
Svals = [S*ones(M,1) Svals]; % insert initial price
plot(tvals,Svals(1:20,:))
If you find this hard to understand try this example:
A=[1 2 3; 4 5 6 ; 7 8 9]
cumprod(A,1)
cumprod(A,2)
35/ 35