Monte Carlo method for multi-dimensional integration.

In mathematics, Monte Carlo integration is a technique for numerical integration using random numbers. It is a particular Monte Carlo method that numerically computes a definite integral. While other algorithms usually evaluate the integrand at a regular grid, Monte Carlo randomly choose points at which the integrand is evaluated. This method is particularly useful for higher-dimensional integrals. There are different methods to perform a Monte Carlo integration, such as uniform sampling, stratified sampling and importance sampling.

Inheritance: INumericalIntegration, IMultidimensionalIntegration
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        ///
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        ///
        public object Clone()
        {
            var clone = new MonteCarloIntegration(this.NumberOfParameters, this.Function);

            clone.Iterations = Iterations;
            clone.Range      = (DoubleRange[])Range.Clone();

            return(clone);
        }
        /// <summary>
        ///   Computes the area of the function under the selected <see cref="Range"/>.
        ///   The computed value will be available at this object's <see cref="Area"/>.
        /// </summary>
        ///
        /// <returns>
        ///   True if the integration method succeeds, false otherwise.
        /// </returns>
        ///
        public static double Integrate(Func <double[], double> func, double[] a, double[] b)
        {
            var mc = new MonteCarloIntegration(a.Length, func);

            for (int i = 0; i < a.Length; i++)
            {
                mc.Range[i] = new DoubleRange(a[i], b[i]);
            }
            mc.Compute();
            return(mc.Area);
        }
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        /// 
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        /// 
        public object Clone()
        {
            var clone = new MonteCarloIntegration(this.NumberOfParameters, this.Function);

            clone.Iterations = Iterations;
            clone.Range = (DoubleRange[])Range.Clone();

            return clone;
        }
 /// <summary>
 ///   Computes the area of the function under the selected <see cref="Range"/>.
 ///   The computed value will be available at this object's <see cref="Area"/>.
 /// </summary>
 /// 
 /// <returns>
 ///   True if the integration method succeeds, false otherwise.
 /// </returns>
 /// 
 public static double Integrate(Func<double[], double> func, double[] a, double[] b)
 {
     var mc = new MonteCarloIntegration(a.Length, func);
     for (int i = 0; i < a.Length; i++)
         mc.Range[i] = new DoubleRange(a[i], b[i]);
     mc.Compute();
     return mc.Area;
 }