Esempio n. 1
0
        // Sample a pre-determined number of points using the given generator and grid and return the average function value.

        private static double Integrate_MonteCarlo_Cycle(MultiFunctor f, CoordinateTransform[] map, VectorGenerator g, LePageGrid grid, int n)
        {
            double sum = 0.0;

            for (int i = 0; i < n; i++)
            {
                double[] x = g.NextVector();
                //sum += f.Evaluate(x);
                sum += grid.Evaluate(f, map, x);
            }

            return(sum / n);
        }
        // Sample a pre-determined number of points using the given generator and grid and return the average function value.
        private static double Integrate_MonteCarlo_Cycle(MultiFunctor f, CoordinateTransform[] map, VectorGenerator g, LePageGrid grid, int n)
        {
            double sum = 0.0;

            for (int i = 0; i < n; i++) {
                double[] x = g.NextVector();
                //sum += f.Evaluate(x);
                sum += grid.Evaluate(f, map, x);
            }

            return (sum / n);
        }