Monte Carlo - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Monte Carlo

Description:

GAUSS will normally take the system time as the seed value, this is pretty much a random event. ... Generating Random Numbers in GAUSS ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 29
Provided by: Sha196
Category:
Tags: carlo | gauss | monte

less

Transcript and Presenter's Notes

Title: Monte Carlo


1
Monte Carlo
2
Monte Carlo studies are one of the earliest
computer techniques, dating back to the 1940s,
they allow us to analyse a range of questions
which are not directly tractable to an analytical
solution.   Sometimes these problems may be
simply so complex that we can not work out the
large sample (asymptotic) answer. In other cases
we may be interested in the answer for a small
sample size or a limited number of states which
are not easily calculated.   This technique has
an enormous range of applications, pure
statistics, project appraisal, macroeconomic
models, derivative pricing almost anywhere
where there are either stochastic processes or
intractable mathematical formulas.
3
The essence of the technique is to assume a known
world (DGP), to assume something about the
statistical distribution of certain events.
Then to numerically draw many realisations from
this distribution. Calculate the outcome and
analyse the resulting distribution of solutions.
4
A simple example from Metropolis and
Ulam   Suppose we wish to evaluate the relative
volume of a region in 20 dimensional space where
the region is defined by 20 non linear
inequalities as follows,
Where we define the xs to lie in a unit cube.
5
In effect we are asking what is the proportion of
points in this space which lie inside these
inequalities.   For some simple functions it may
be possible using integration to solve this
analytically but generally this will not be
possible.
We could think of dividing up the unit interval
into say 10 sections for each x and then checking
each point this would lead to checking
100,000,000,000,000,000,000 different points.
6
The monte carlo approach would take the above set
of equations as the DGP, assume the xs are
generated by an independent uniform distribution
over the unit interval. It would then generate
say 5000 random draws from this distribution.
It would then calculate what proportion of
these draws are in the area defined above. This
would then be an approximation to the size of the
area.
7
A Statistical Example   If we have a symmetric
distribution such as the normal or t, we know
that the mean and the median should be identical
in terms of their asymptotic properties. But
what about in a small sample? Intuitively if
the sample is very small we might expect the mean
to do badly because any outlier will be given too
much weight. In a bigger sample the mean may be
a better. But where is the divide, and is this
true.
8
A Monte Carlo   Draw a set of n observations
from a t distribution with d degrees of
freedom.   Calculate the mean and the
median.   Repeat this R times.   Tabulate the
relative error ratio of the median to the mean
9
 
So the median does best for nlt25 and dlt6
 
10
Project Appraisal     We can evaluate the likely
profitability of a project using these techniques
in the light of many uncertainties using this
technique.     Build a model of the cash flow of
the project which calculates the net present
value as an output.
11
Draw random realisations of the uncertain factors
which might affect the project.     Repeat many
simulations.     Calculate the distribution of
the net present value.     This gives the
probability of making a profit and a standard
error around this. So we can asses how uncertain
we are about this mean forecast. We can also
asses the probability of making a loss of a
particular size.  
12
Generating random numbers   In fact all computer
generated random numbers come from a fixed
deterministic sequence which is highly non-linear
so that the numbers appear random. They are
therefore called pseudo-random numbers. Most
computers start with a uniform random number over
the interval 0-1, and then transform this to
derive particular distributions.   Because the
numbers are generated from a formulae the set of
numbers depends on an initial value which starts
of the whole sequence. This is called the seed.
13
GAUSS will normally take the system time as the
seed value, this is pretty much a random
event.   Sometimes it is useful to produce
identical sequences of random numbers then we can
set the seed to an actual value.
This is done with this command   rndseed 1000
or any other fixed number   Generating
Random Numbers in GAUSS  
14
Having either defined a seed or used the default
of the system clock to seed the process we can
then generate a series of uniform random numbers
by,   yrndu(r,c) where r is the
number of rows
And c the number of columns
So   yrndu(5,1) would create a column
of 5 uniform
random numbers
15
similarly normal (0,1) random numbers are
generated by,   yrndn(r,c)
we can then transform these as we want, so if we
want a set of 50 normal numbers with mean 10 and
variance 25 (standard error 5),   x10y5 yrndn
(50,1)
Other distributions can be created by
transforming these random numbers (see Hendry
article).
16
Increasing efficiency   There are a range of
tricks which allow us to increase the efficiency
of a monte carlo.
Antithetic Variates   If we are interested in
estimating the mean of a process then this trick
can increase the efficiency of the monte carlo
enormously.   The idea is that we perform the
simulations in pairs, the second one of the pair
uses the same absolute values for the random
shocks but with the opposite sign. This
guarantees that we are always using an exactly
symmetric distribution.
17
Control Variates   This is a technique which is
problem specific but it really amounts to using
our knowledge of the structure of the problem to
increase the efficiency of the replications.
This will generally involve adding restrictions
on the way the model works to ensure that it
exactly follows our prior beliefs in some way.
See the Boyle et al paper.
18
So to generate antithetic values for
z.   yrndn(50,1) x10y5 i1 do while ilt2
if i1 zx elseif igt1 z-x
endif ii1 endo  
Note this does not help if we are interested in
assessing the variance of an outcome.
19
Moment Matching   This is a generalisation of
antithetics. The idea is that we transform the
random numbers in each replication to exactly
match some of the moments of the underlying
distribution.
So to exactly match the zero mean
assumption.   yrndn(50,1) ameanc(y) bstdc(y)
z(y-a)(1/b) x10z5
There are also a range of more specialised
techniques surveyed in Boyle.
20
Option Pricing through Monte Carlo.   In the case
of a standard European call option we can use
Black-Scholes, but we can illustrate the monte
carlo approach to get the same answer.
If S0 is the current stock price, r is the
riskless rate of return, I
is the conditional variance of the stock, T is
the maturity date and z are independent standard
normal random numbers. Then for a particular
realisation of z the price at T is,
21
So the price of the option with strike K will be
given by
This can be approximated in a monte carlo by
22
profit
Strike price
mean
S0
T
23
and if we assumed some other process to generate
ST , or a variable strike price or a different
distribution of shocks etc. we can still perform
the simulation.
24
MONTE3.JOB A MONTE CARLO SIMULATION for
derivative pricing with antithetics   period
50 reps500 tau5/12 reps2reps2 i1 m0 c
ls print "replications " reps print "Number
of periods per year ahead " period print
"proportion of a year for duration (tau) "
tau nobstrunc(periodtau)
25
_at_calcualte period standard error to compund up to
0.15_at_ c 0 c1( (0.152)/period)0.5   pr
int "Standard error of returns" print
c1 xzeros(1,reps2) yzeros(1,reps2) zzeros(
1,reps2) wzeros(1,reps2) pzeros(nobs,1) rndse
ed 23456567 p1,162 strike60   _at_calculates
period rate from an anual rate of 10
_at_  r(10.10)(1/period)-1
26
do while iltreps e rndn(nobs,1) _at_
GENERATE NORMAL ERRORS _at_   j1 do while
jlt2   if j lt 1 k1
do while kltnobs kk1
pk,1exp( ln(pk-1,1) r ekc1 )
endo else k1 do
while kltnobs kk1
pk,1exp(ln(pk-1,1) r - ekc1 )
endo endif
This simulates the path of the asset price
27
if pnobs,1gtstrike callprofpnobs,1-str
ike putprof0 else
callprof0 putprofstrike-pnobs,1
endif   mm1 x1,mcallprof
y1,mputprof z1,mpnobs,1   jj1
endo ii1 endo
This decides if the put or call is in profit and
collects up the profit values
28
mmeanc(z') sestdc(z')   mmeanc(x') sestdc(
x') cpm1,1(1/(1r))nobs print "call price
" cp   nmeanc(y') sestdc(y') ppn1,1(1/(
1r))nobs print "put price " pp  end
Takes the mean of all the call profits, discounts
it back to today, thats the call price
Takes the mean of all the put profits, discounts
it back to today and thats the put price
Write a Comment
User Comments (0)
About PowerShow.com