/* * Implements variance reduction techniques for the example * CallCenterDisc.java. * Written by Mario Pouchet et Pierre L'Ecuyer. */ import umontreal.iro.lecuyer.simevents.*; import umontreal.iro.lecuyer.rng.*; import umontreal.iro.lecuyer.randvar.*; import umontreal.iro.lecuyer.probdist.*; import umontreal.iro.lecuyer.stat.*; import umontreal.iro.lecuyer.util.PrintfFormat; import java.io.*; import java.util.LinkedList; import cern.colt.list.DoubleArrayList; public class CallCenterEi extends CallCenterDisc { // Constructor. public CallCenterEi (String fileName, String fileName2) throws IOException { super (fileName, fileName2); } // To simplify the writing in the code. private void println (String s) { System.out.println (s); } private void println () { System.out.println (); } private String f (double x) { return PrintfFormat.f (9, 3, x); } // Compute and print confidence interval with control variate. private void computeCICV (DoubleArrayList A, DoubleArrayList X, double beta, double varMC) { Tally statCV = new Tally (); for (int i = 0; i < A.size(); i++) { statCV.add (X.get(i) - beta * (A.get(i) - nCallsExpected)); } println (statCV.reportAndCIStudent (0.9)); println ("meanX = " + f (statCV.average()) + ", Var(X) = " + f(statCV.variance()) + ", ratio = " + f(statCV.variance() / varMC)); println (); } // ************************************************************* // Simulation experiments without stratification. // Uses n simulation runs and n0 pilot runs. Returns varMC. private double simul (int n, int n0) { println ("**** Simulations without stratification ****"); for (int t=0; t