Calculate() public static method

public static Calculate ( double t1, double t2, double simEnd, int numSim, int numSteps, double &val, double &stDev ) : void
t1 double
t2 double
simEnd double
numSim int
numSteps int
val double
stDev double
return void
Esempio n. 1
0
        public void Test()
        {
            // Try several different simulation dates with the same bound.
            double mcDevST;
            int    numTries = 21;
            double min, max, val;

            min = 0.0;
            max = 2.0;
            Vector timeVector  = Vector.Linspace(min, max, numTries);
            Vector priceVector = new Vector(numTries);

            for (int j = 0; j < numTries; j++)
            {
                PelsserBond.Calculate(0.0, 1.0, timeVector[j], 10000, 100, out val, out mcDevST);
                priceVector[j] = val;
            }

            // The benchmark value with 35000 paths
            double theoreticalValue = 0.95121;

            Console.WriteLine("Benchmark  Bond = " + theoreticalValue);
            Console.WriteLine("Fairmat Bond = ");
            for (int j = 0; j < numTries; j++)
            {
                Console.WriteLine("Simulation Time = " + timeVector[j] + "\t Bond Price = " + priceVector[j]);
            }
        }
Esempio n. 2
0
        public void Test()
        {
            // Comparison with the benchmark of the expected value of  P(5,6)
            double mcPrice;
            double mcDevST;

            PelsserBond.Calculate(5.0, 6.0, 6.0, 100000, 200, out mcPrice, out mcDevST);

            // The benchmark value with 35000 paths
            // double theoreticalValue = 0.95109;
            double RightValue = 0.951276263137499;

            Console.WriteLine("Benchmark  Bond = " + RightValue);
            Console.WriteLine("Fairmat Bond = " + mcPrice);
            Console.WriteLine("Standard Deviation = " + mcDevST);
            double tol = 5.0 * mcDevST;

            Assert.Less(Math.Abs(RightValue - mcPrice), tol);
        }
Esempio n. 3
0
        protected bool Run(double h)
        {
            // Try several different simulation dates with the same bond.
            double mcDevST;
            double val;

            PelsserBond.Calculate(0.0, 1.0, h, 10000, 100, out val, out mcDevST);

            double theoreticalValue = 0.951228651454765;

            double diff = theoreticalValue - val;

            Console.WriteLine("Simulation horizon\t" + h);
            Console.WriteLine("Diff:\t" + (100 * diff / theoreticalValue) + "%");
            if (Math.Abs(diff) > 10e-6)
            {
                return(false);
            }
            return(true);
        }