k=0,...,numberOfRealisations-1
) samples modeling
each one possible evolution of the asset (currentState[k][0]
) and
an equal number of markers (mark[k][0]
) to account for barriers
in exotic options, the
initialization in SamplingSolution.java
has been implemented as
numberOfRealisations = runData.getParamValueInt("Walkers"); strike = runData.getParamValue("StrikePrice"); kappa = runData.getParamValue("LogNkappa"); //Separable if( (Math.abs(kappa)<0.001) ||(Math.abs(kappa-1.)<0.001)){ currentState = new double[numberOfRealisations][1]; for (k=0; k<numberOfRealisations; k++) currentState[k][0]=strike; //Barriers if(scheme.equals(vmarket.MCIN)||scheme.equals(vmarket.MCINPP)){ mark = new double[numberOfRealisations][1]; for (k=0; k<numberOfRealisations; k++) mark[k][0]=0.; } else if (scheme.equals(vmarket.MCOUT)||scheme.equals(vmarket.MCOUTPP)){ mark = new double[numberOfRealisations][1]; for (k=0; k<numberOfRealisations; k++) mark[k][0]=1.; }If the parameter
kappa
is sufficiently close to log-/normal with
currentState[k][0]
with numberOfRealisations
samples of
one single price stored in a one dimensional array with an idle index
[0]
; the entire array is (arbitrarily or, rather, for plotting)
initialized with the strike price currentState[k][0]=strike
.
The value of the selector scheme
decides if the modeling of
an in-/out-barrier option with-/out particle plotting requires the
creation of an additional marker array mark[k][0]
, which has
to be initialized with the corresponding behavior.
Not shown in the code above but visible in the
VMARKET listing, is that a parameter kappa
sufficiently different from zero
or one can be used to initialize a two dimensional array
currentState[k][j]
with j=0,..., mesh.size()-1
different prices; these are evolved in parallel if the problem is
not separable-e.g. when the increments depend in a non-trivial
manner on the asset price.
currentState[k][0]
are
calculated in MCSSolution.java
repeating for each step
double timeStep = runData.getParamValue("TimeStep"); double strike = runData.getParamValue("StrikePrice"); double mu = runData.getParamValue("Drift"); double divid = runData.getParamValue("Dividend"); double sigma = runData.getParamValue("Volatility"); double barrier = runData.getParamValue("Barrier"); if(Math.abs(kappa-1.)<0.001){ //Separable log-normal for(int k=0; k<numberOfRealisations; k++) currentState[k][0]+= currentState[k][0]*( (mu-divid)*timeStep + random.nextGaussian()*sigma*Math.sqrt(timeStep) ); //Barriers if (scheme.equals(vmarket.MCOUT) || scheme.equals(vmarket.MCOUTPP)){ for(int k=0; k<numberOfRealisations; k++) if ((barrier >= 0. && currentState[k][0]-strike > strike*barrier)|| (barrier < 0. && currentState[k][0]-strike < strike*barrier) ) mark[k][0]=0.; } else if (scheme.equals(vmarket.MCIN) || scheme.equals(vmarket.MCINPP)){ for(int k=0; k<numberOfRealisations; k++) if ((barrier >= 0. && currentState[k][0]-strike > strike*barrier)|| (barrier < 0. && currentState[k][0]-strike < strike*barrier) ) mark[k][0]=1.; } }The first four lines compute the deterministic
(mu-divid)*timeStep
and
the random component random.nextGaussian()*sigma*Math.sqrt(timeStep)
of the evolution, which are easily identified as the right-hand side of
(4.5.1#eq.1).
Further scaling by the underlying asset price currentState[k][0]
reproduces the log-normal distribution of the increments, which are finally
accumulated with the Java operator currentState[k][0]+=increment
.
The variable mark[k][0]
is reset to zero (alt. one) whenever the
condition for an ``out-'' (alt. ``in-'') barrier is met for a given sample.
Note that the position of the barrier is here defined relative to the
initial condition, using a positive (alt. negative) value of the variable
barrier
to distinguish a barrier above (alt. below) the initial
price of the underlying.
This relative definition is here required to keep the problem separable, so
that the evolution of any price SYLLABUS Previous: 4.5 Methods for European Up: 4.5 Methods for European Next: 4.5.2 Expected value of