Beispiel #1
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StochasticProcess1D obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
 public GaussianSobolPathGenerator(StochasticProcess1D process, double length, uint steps, GaussianLowDiscrepancySequenceGenerator rsg, bool brownianBridge) : this(NQuantLibcPINVOKE.new_GaussianSobolPathGenerator(StochasticProcess1D.getCPtr(process), length, steps, GaussianLowDiscrepancySequenceGenerator.getCPtr(rsg), brownianBridge), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #3
0
        public void testSingle(StochasticProcess1D process,
                               string tag,
                               bool brownianBridge,
                               double expected,
                               double antithetic)
        {
            ulong  seed      = 42;
            double length    = 10;
            int    timeSteps = 12;

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



            PathGenerator <IRNG> generator = new PathGenerator <IRNG>(process,
                                                                      length,
                                                                      timeSteps,
                                                                      rsg,
                                                                      brownianBridge);
            int i;

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

            Sample <Path> sample     = generator.next();
            double        calculated = sample.value.back();
            double        error      = Math.Abs(calculated - expected);
            double        tolerance  = 2.0e-8;

            if (error > tolerance)
            {
                Assert.Fail("using " + tag + " process "
                            + (brownianBridge ? "with " : "without ")
                            + "brownian bridge:\n"
                            //+ std::setprecision(13)
                            + "    calculated: " + calculated + "\n"
                            + "    expected:   " + expected + "\n"
                            + "    error:      " + error + "\n"
                            + "    tolerance:  " + tolerance);
            }

            sample     = generator.antithetic();
            calculated = sample.value.back();
            error      = Math.Abs(calculated - antithetic);
            tolerance  = 2.0e-7;
            if (error > tolerance)
            {
                Assert.Fail("using " + tag + " process "
                            + (brownianBridge ? "with " : "without ")
                            + "brownian bridge:\n"
                            + "antithetic sample:\n"
                            //+ setprecision(13)
                            + "    calculated: " + calculated + "\n"
                            + "    expected:   " + antithetic + "\n"
                            + "    error:      " + error + "\n"
                            + "    tolerance:  " + tolerance);
            }
        }
 public GaussianPathGenerator(StochasticProcess1D process, TimeGrid timeGrid, GaussianRandomSequenceGenerator rsg, bool brownianBridge) : this(NQuantLibcPINVOKE.new_GaussianPathGenerator__SWIG_1(StochasticProcess1D.getCPtr(process), TimeGrid.getCPtr(timeGrid), GaussianRandomSequenceGenerator.getCPtr(rsg), brownianBridge), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StochasticProcess1D obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
 public GaussianSobolPathGenerator(StochasticProcess1D process, double length, uint steps, GaussianLowDiscrepancySequenceGenerator rsg, bool brownianBridge) : this(NQuantLibcPINVOKE.new_GaussianSobolPathGenerator(StochasticProcess1D.getCPtr(process), length, steps, GaussianLowDiscrepancySequenceGenerator.getCPtr(rsg), brownianBridge), true) {
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
 }