예제 #1
0
    private static void test11()

    //****************************************************************************
    //
    //  Purpose:
    //
    //    TEST11 tests STOCHASTIC_INTEGRAL_STRAT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    28 September 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double error    = 0;
        double estimate = 0;
        double exact    = 0;
        int    i;

        Console.WriteLine("");
        Console.WriteLine("TEST11:");
        Console.WriteLine("  Estimate the Stratonovich integral of W(t) dW over [0,1].");
        Console.WriteLine("");
        Console.WriteLine("                                                 Abs          Rel");
        Console.WriteLine("         N        Exact        Estimate          Error        Error");
        Console.WriteLine("");

        int n    = 100;
        int seed = 123456789;

        typeMethods.r8vecNormalData data = new();

        for (i = 1; i <= 7; i++)
        {
            Integrals.stochastic_integral_strat(n, ref data, ref seed, ref estimate, ref exact, ref error);

            Console.WriteLine("  " + n.ToString().PadLeft(8)
                              + "  " + exact.ToString(CultureInfo.InvariantCulture).PadLeft(16)
                              + "  " + estimate.ToString(CultureInfo.InvariantCulture).PadLeft(16)
                              + "  " + error.ToString(CultureInfo.InvariantCulture).PadLeft(16)
                              + "  " + (error / exact).ToString(CultureInfo.InvariantCulture).PadLeft(16) + "");

            n *= 4;
        }
    }