13 public TestAsianRQMCSeries(
double r,
double sigma,
double strike,
double s0,
int s,
double[] zeta) {
14 super(r, sigma, strike, s0, s, zeta);
27 public int getDimension() {
32 return "Asian option under GBM, for testing";
36 return "AsianRQMCSeries";
39 public static void main(String[] args)
throws IOException {
43 double[] zeta =
new double[s + 1];
44 for (
int j = 0; j <= s; j++)
45 zeta[j] = (
double) j / (double) s;
47 Tally statValue =
new Tally(
"value of Asian option");
52 System.out.println(
"Ordinary MC:\n");
61 int[] N = { 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152 };
62 int[] a = { 149, 275, 857, 1731, 2431, 6915, 12545, 19463, 50673, 96407, 204843, 443165, 768165 };
65 ArrayList<RQMCPointSet[]> listOfSeries =
new ArrayList<RQMCPointSet[]>();
67 PointSetRandomization rand;
68 RandomStream noise =
new MRG32k3a();
71 RQMCPointSet[] theRQMCSetLattice =
new RQMCPointSet[numSets];
72 rand =
new RandomShift(noise);
73 for (i = 0; i < numSets; ++i) {
74 p =
new BakerTransformedPointSet(
new KorobovLattice(N[i], a[i], dim));
75 theRQMCSetLattice[i] =
new RQMCPointSet(p, rand);
77 theRQMCSetLattice[0].
setLabel(
"Lattice+baker+shift");
78 listOfSeries.add(theRQMCSetLattice);
81 RQMCPointSet[] theRQMCSetSobol =
new RQMCPointSet[numSets];
83 rand =
new LMScrambleShift(noise);
84 for (i = 0; i < numSets; ++i) {
85 p = (
new SobolSequence(i + mink, 31, dim));
86 theRQMCSetSobol[i] =
new RQMCPointSet(p, rand);
88 theRQMCSetSobol[0].
setLabel(
"Sobol+LMS+Shift");
89 listOfSeries.add(theRQMCSetSobol);
91 RQMCExperimentSeries experSeries =
new RQMCExperimentSeries(theRQMCSetLattice, base);
94 System.out.println((experSeries.
toPgfDataTable(
"Korobov+baker")).drawPgfPlotSingleCurve(
"Korobov+baker",
"axis",
95 3, 4, 2,
"",
"marks=*"));
98 ArrayList<PgfDataTable> listCurves =
new ArrayList<PgfDataTable>();
101 System.out.println(
"\n Now printing data table for the two curves ***** \n\n\n");
103 for (PgfDataTable curve : listCurves)
104 System.out.println(curve.formatTable());
106 String plot = PgfDataTable.drawPgfPlotManyCurves(
"Korobov and Sobol",
"loglogaxis", 0, 2, listCurves, 2,
"",
" ");
107 System.out.println(plot);
110 String pfile = (PgfDataTable.pgfplotFileHeader() + plot + PgfDataTable.pgfplotEndDocument());
111 Writer file =
new FileWriter(
"testPlotAsianRQMC.tex");