private static void test01() //****************************************************************************80 // // Purpose: // // TEST01 compares exact and estimated integrals in 3D. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 16 January 2014 // // Author: // // John Burkardt // { const int m = 3; const int n = 4192; int test; const int test_num = 20; Console.WriteLine(""); Console.WriteLine("TEST01"); Console.WriteLine(" Estimate monomial integrals using Monte Carlo"); Console.WriteLine(" over the interior of the unit simplex in M dimensions."); // // Get sample points. // int seed = 123456789; double[] x = Integrals.simplex01_sample(m, n, ref seed); Console.WriteLine(""); Console.WriteLine(" Number of sample points used is " + n + ""); // // Randomly choose exponents. // Console.WriteLine(""); Console.WriteLine(" We randomly choose the exponents."); Console.WriteLine(""); Console.WriteLine(" Ex Ey Ez MC-Estimate Exact Error"); Console.WriteLine(""); for (test = 1; test <= test_num; test++) { int[] e = UniformRNG.i4vec_uniform_ab_new(m, 0, 4, ref seed); double[] value = Monomial.monomial_value(m, n, e, x); double result = Integrals.simplex01_volume(m) * typeMethods.r8vec_sum(n, value) / n; double exact = Integrals.simplex01_monomial_integral(m, e); double error = Math.Abs(result - exact); Console.WriteLine(" " + e[0].ToString().PadLeft(2) + " " + e[1].ToString().PadLeft(2) + " " + e[2].ToString().PadLeft(2) + " " + result.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + exact.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + error.ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } }