Example #1
0
 public GaussianPathGenerator(StochasticProcess arg0, TimeGrid timeGrid, GaussianRandomSequenceGenerator generator, bool brownianBridge) : this(NQuantLibcPINVOKE.new_GaussianPathGenerator__SWIG_1(StochasticProcess.getCPtr(arg0), TimeGrid.getCPtr(timeGrid), GaussianRandomSequenceGenerator.getCPtr(generator), brownianBridge), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #2
0
 public GaussianMultiPathGenerator(StochasticProcess process, DoubleVector times, GaussianRandomSequenceGenerator generator) : this(NQuantLibcPINVOKE.new_GaussianMultiPathGenerator__SWIG_1(StochasticProcess.getCPtr(process), DoubleVector.getCPtr(times), GaussianRandomSequenceGenerator.getCPtr(generator)), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #3
0
 public GaussianPathGenerator(StochasticProcess arg0, double length, uint timeSteps, GaussianRandomSequenceGenerator generator, bool brownianBridge) : this(NQuantLibcPINVOKE.new_GaussianPathGenerator__SWIG_0(StochasticProcess.getCPtr(arg0), length, timeSteps, GaussianRandomSequenceGenerator.getCPtr(generator), brownianBridge), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public InvCumulativeMersenneTwisterPathGenerator(StochasticProcess arg0, TimeGrid timeGrid, InvCumulativeMersenneTwisterGaussianRsg generator, bool brownianBridge) : this(NQuantLibcPINVOKE.new_InvCumulativeMersenneTwisterPathGenerator__SWIG_1(StochasticProcess.getCPtr(arg0), TimeGrid.getCPtr(timeGrid), InvCumulativeMersenneTwisterGaussianRsg.getCPtr(generator), brownianBridge), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #5
0
 protected MCAutocallEngine(StochasticProcess process, int timeSteps, int timeStepsPerYear, bool brownianBridge,
                            bool antitheticVariate, bool controlVariate, int requiredSamples, double requiredTolerance, int maxSamples, ulong seed)
 //protected MCVanillaEngine(StochasticProcess process, int timeSteps, int timeStepsPerYear, bool brownianBridge,
 //                          bool antitheticVariate, bool controlVariate, int requiredSamples, double requiredTolerance,
 //                          int maxSamples, ulong seed)
     : base(process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, requiredSamples,
            requiredTolerance, maxSamples, seed)
 {
 }
Example #6
0
        public static GsrProcess as_gsr_process(StochasticProcess proc)
        {
            GsrProcess ret = new GsrProcess(NQuantLibcPINVOKE.as_gsr_process(StochasticProcess.getCPtr(proc)), true);

            if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
            {
                throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #7
0
        public void testMultiple(StochasticProcess process,
                                 string tag,
                                 double[] expected,
                                 double[] antithetic)
        {
            ulong  seed      = 42;
            double length    = 10;
            int    timeSteps = 12;
            int    assets    = process.size();

            var rsg = (InverseCumulativeRsg <RandomSequenceGenerator <MersenneTwisterUniformRng>
                                             , InverseCumulativeNormal>)
                      new PseudoRandom().make_sequence_generator(timeSteps * assets, seed);

            MultiPathGenerator <IRNG> generator = new MultiPathGenerator <IRNG>(process,
                                                                                new TimeGrid(length, timeSteps),
                                                                                rsg, false);
            int i;

            for (i = 0; i < 100; i++)
            {
                generator.next();
            }

            Sample <MultiPath> sample = generator.next();
            Vector             calculated = new Vector(assets);
            double             error, tolerance = 2.0e-7;

            for (int j = 0; j < assets; j++)
            {
                calculated[j] = sample.value[j].back();
            }

            for (int j = 0; j < assets; j++)
            {
                error = Math.Abs(calculated[j] - expected[j]);
                if (error > tolerance)
                {
                    Assert.Fail("using " + tag + " process "
                                + "(" + j + 1 + " asset:)\n"
                                //+ std::setprecision(13)
                                + "    calculated: " + calculated[j] + "\n"
                                + "    expected:   " + expected[j] + "\n"
                                + "    error:      " + error + "\n"
                                + "    tolerance:  " + tolerance);
                }
            }

            sample = generator.antithetic();
            for (int j = 0; j < assets; j++)
            {
                calculated[j] = sample.value[j].back();
            }
            for (int j = 0; j < assets; j++)
            {
                error = Math.Abs(calculated[j] - antithetic[j]);
                if (error > tolerance)
                {
                    Assert.Fail("using " + tag + " process "
                                + "(" + j + 1 + " asset:)\n"
                                + "antithetic sample:\n"
                                //+ std::setprecision(13)
                                + "    calculated: " + calculated[j] + "\n"
                                + "    expected:   " + antithetic[j] + "\n"
                                + "    error:      " + error + "\n"
                                + "    tolerance:  " + tolerance);
                }
            }
        }
Example #8
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StochasticProcess obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
 public GaussianMultiPathGenerator(StochasticProcess process, DoubleVector times, GaussianRandomSequenceGenerator generator) : this(NQuantLibcPINVOKE.new_GaussianMultiPathGenerator__SWIG_1(StochasticProcess.getCPtr(process), DoubleVector.getCPtr(times), GaussianRandomSequenceGenerator.getCPtr(generator)), true) {
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
 }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StochasticProcess obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }