Class SamplingSolution

java.lang.Object
  extended bySolution
      extended bySamplingSolution
Direct Known Subclasses:
MCSSolution

abstract class SamplingSolution
extends Solution

SamplingSolution -- Is an abstract class at the top of all the solvers that that evolve an expected solution by sampling possible realisation.

Version:
$Revision: 1.10 $
See Also:
Solution

Field Summary
protected  double[][] currentState
          A vector with the current realisation(s) evolved from initial price(s)
protected  double kappa
          The exponent in the random walk
protected  double[][] mark
          A vector with the current markers keeping track of price history
protected  int numberOfRealisations
          The number of independent realisations to evolve
protected  ShapeFunction option
          The terminal payoff
protected  java.util.Random random
          Random number generator
protected  double rate
          The interest rate
protected  boolean solutionUpToDate
          Whether the expected solution is up to date
protected  double strike
          The default initial / terminal condition
 
Fields inherited from class Solution
df, dfm, dfp, dg, dgm, dgp, dx, f, f0, fm, fp, g, gm, gp, ic, initialMoments, mesh, method, scheme, time, topic, x, x_0, x_1, xOffset, xSize, y_0, y_1, yOffset, ySize
 
Constructor Summary
SamplingSolution(RunData runData)
          Creates a SamplingSolution object.
 
Method Summary
 void discretize(ShapeFunction function)
          Discretize the initial Shape function and initialize the moments Initializes a new set of particles, the number being determined by the numerical scheme parameter.
protected  void expectedValue()
          Generates a probability distribution and an expectation from the set of sampled values.
 double getValue(double arg)
          Linear interpolation of the solution.
 double getValue(int index)
          Gives the value of the function for an index
 double[] limits()
          Calculates the limits of the solution.
 double momentsDeviation(int m)
          Calculates the deviation from the m:th initial moment.
 boolean previous(RunData runData)
          Take the solution backward one step to initialize schemes with 3 time levels; not really appropriate in this context.
 
Methods inherited from class Solution
calculateMoments, getTime, getWinSize, hasOption, incTime, limits, measure, next, output, plot, rescale, setIC, setMethod, setScheme, setTime, setTopic, updateHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

option

protected ShapeFunction option
The terminal payoff


numberOfRealisations

protected int numberOfRealisations
The number of independent realisations to evolve


currentState

protected double[][] currentState
A vector with the current realisation(s) evolved from initial price(s)


mark

protected double[][] mark
A vector with the current markers keeping track of price history


kappa

protected double kappa
The exponent in the random walk


rate

protected double rate
The interest rate


strike

protected double strike
The default initial / terminal condition


solutionUpToDate

protected boolean solutionUpToDate
Whether the expected solution is up to date


random

protected java.util.Random random
Random number generator

Constructor Detail

SamplingSolution

public SamplingSolution(RunData runData)
Creates a SamplingSolution object. Note that discretize must be called before next is called for the first time.

Parameters:
runData - The run time parameters
See Also:
Solution.next(RunData), Solution.discretize(ShapeFunction)
Method Detail

previous

public boolean previous(RunData runData)
Take the solution backward one step to initialize schemes with 3 time levels; not really appropriate in this context.

Specified by:
previous in class Solution
Parameters:
runData - List of run parameters
Returns:
False since it is not used here
See Also:
RunData

discretize

public void discretize(ShapeFunction function)
Discretize the initial Shape function and initialize the moments Initializes a new set of particles, the number being determined by the numerical scheme parameter.

Specified by:
discretize in class Solution
Parameters:
function - The initial shape to be approximated
See Also:
Solution.setScheme(java.lang.String)

momentsDeviation

public double momentsDeviation(int m)
Calculates the deviation from the m:th initial moment.

Overrides:
momentsDeviation in class Solution
Parameters:
m - The order of the moment
Returns:
The deviation of the m:th moment from the beginning

limits

public double[] limits()
Calculates the limits of the solution.

Returns:
A vector consisting of {min(solution), max(solution)}

getValue

public double getValue(int index)
Gives the value of the function for an index

Overrides:
getValue in class Solution
Parameters:
index - The index for which to get the value
Returns:
The value of the distribution function at a given index

getValue

public double getValue(double arg)
Linear interpolation of the solution. Assumes a uniform mesh.

Overrides:
getValue in class Solution
Parameters:
arg - Argument
Returns:
A linear interpolation of the function for a given argument

expectedValue

protected void expectedValue()
Generates a probability distribution and an expectation from the set of sampled values. Assumes a uniform mesh.