コード例 #1
0
    private double KLExpansion(double s, double t)
    { // W(s) - W(t) for s > t
        double result = 0.0;

        for (int n = 0; n <= N; n++)
        {
            result += (OrthogonalFunction(s, n) - OrthogonalFunction(t, n)) * rng.GenerateRn();
        }

        return(result);
    }
コード例 #2
0
    public void start()
    {
        T VOld, VNew;

        for (long i = 1; i <= NSim; ++i)
        {     // Calculate a path at each iteration
            if ((i / 5000) * 5000 == i)
            { // Give status after a given numbers of iterations
                Console.WriteLine(i);
            }

            VOld = sde.InitialCondition; res[0] = VOld;

            for (int n = 1; n < res.Length; n++)
            { // Compute the solution at level n+1
                VNew   = fdm.advance(VOld, fdm.x[n - 1], fdm.k, rng.GenerateRn(), rng.GenerateRn());
                res[n] = VNew; VOld = VNew;
            }

            path(ref res);
        }
        finish();
    }
コード例 #3
0
ファイル: Mediator.cs プロジェクト: songgaoxian/Advanced_C
    public void start()
    { // Main event loop for path generation
        double VOld, VNew;

        for (int i = 1; i <= NSim; ++i)
        {     // Calculate a path at each iteration
          //   if ((i / 5000) * 5000 == i)
            { // Give status after a given numbers of iterations
                mis(i);
            }

            VOld = sde.InitialCondition; res[0] = VOld;

            for (int n = 1; n < res.Length; n++)
            { // Compute the solution at level n+1
                VNew   = fdm.advance(VOld, fdm.x[n - 1], fdm.k, rng.GenerateRn(), rng.GenerateRn());
                res[n] = VNew; VOld = VNew;
            }

            // Send path data to the Pricers
            path(ref res);
        }
        finish(); // Signal to pricers to finish up
    }