SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
AsianGBMRQMC2.java
1package tutorial;
2
3import java.io.IOException;
4import umontreal.ssj.rng.*;
5import umontreal.ssj.hups.*;
6import umontreal.ssj.mcqmctools.*;
7import umontreal.ssj.stat.Tally;
8
9// An extension of AsianGBM2 that uses an RQMC.
10public class AsianGBMRQMC2 extends AsianGBM2 {
11
12 public AsianGBMRQMC2(double r, double sigma, double strike, double s0, int s, double[] zeta) {
13 super(r, sigma, strike, s0, s, zeta);
14 }
15
16 public static void main(String[] args) throws IOException {
17 int d = 12;
18 double[] zeta = new double[d + 1];
19 for (int j = 0; j <= d; j++)
20 zeta[j] = (double) j / (double) d;
21 AsianGBMRQMC2 model = new AsianGBMRQMC2(0.05, 0.5, 100.0, 100.0, d, zeta);
22 Tally statMC = new Tally("value of Asian option");
23 Tally statRQMC = new Tally("RQMC averages for Asian option under GBM");
24 RandomStream noise = new LFSR113();
25 int n = 100000; // Number of runs for MC.
26 DigitalNet p = new SobolSequence(16, 31, d); // n = 2^{16} RQMC points in d dim.
27 PointSetRandomization rand = new LMScrambleShift(noise);
28 int m = 50; // Number of RQMC randomizations.
29
30 // We first perform a Monte Carlo experiment.
31 System.out.println("Ordinary MC:");
32 System.out.println(MonteCarloExperiment.simulateRunsDefaultReportStudent(model, n, noise, statMC));
33 System.out.println("------------------------\n");
34
35 // Then we make an RQMC experiment.
36 System.out.println("RQMC experiment:");
37 System.out.println(RQMCExperiment.simulReplicatesRQMCDefaultReport(model, p, rand, m, statRQMC));
38 System.out.println("----------------------------------------------------\n");
39
40 // This single function makes both the MC and RQMC experiments and also
41 // compares the variances and efficiencies.
42 System.out.println("Experiment for MC/RQMC comparison:");
43 System.out.println(RQMCExperiment.makeComparisonExperimentMCvsRQMC(model, noise, p, rand, n, m));
44 }
45}
This class provides the basic structures for storing and manipulating linear digital nets in base ,...
This class implements a umontreal.ssj.hups.PointSetRandomization that performs a left matrix scrambli...
This class implements digital nets and digital sequences in base 2 formed by the first points of a S...
Provides generic tools to perform simple Monte Carlo experiments with a simulation model that impleme...
static String simulateRunsDefaultReportStudent(MonteCarloModelDouble model, int n, RandomStream stream, Tally statValue, double level, int d, Chrono timer)
Performs n independent runs using n substreams of stream, collects statistics in statValue,...
Provides basic generic tools to perform RQMC experiments with a simulation model that implements the ...
static String makeComparisonExperimentMCvsRQMC(MonteCarloModelDouble model, RandomStream stream, PointSet p, PointSetRandomization rand, int n, int m, Tally statMC, Tally statRQMC)
This method first performs a MC experiment to estimate the variance and CPU time per run,...
static String simulReplicatesRQMCDefaultReport(MonteCarloModelDouble model, PointSet p, PointSetRandomization rand, int m, Tally statRQMC)
Similar to simulReplicatesRQMC, but also returns a report as a String.
Extends RandomStreamBase using a composite linear feedback shift register (LFSR) (or Tausworthe) RNG ...
Definition LFSR113.java:47
A subclass of StatProbe.
Definition Tally.java:47
This interface is for a randomization that can be used to randomize a umontreal.ssj....
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...