MonteCarloIntegration Class 
Namespace: Accord.Math.Integration
public class MonteCarloIntegration : INumericalIntegration, ICloneable, IMultidimensionalIntegration
The MonteCarloIntegration type exposes the following members.
Name  Description  

MonteCarloIntegration(Int32) 
Constructs a new Monte Carlo integration method.
 
MonteCarloIntegration(Int32, FuncDouble, Double) 
Constructs a new Monte Carlo integration method.

Name  Description  

Area 
Gets the numerically computed result of the
definite integral for the specified function.
 
Error 
Gets the integration error for the
computed Area value.
 
Function 
Gets or sets the multidimensional function
whose integral should be computed.
 
Iterations 
Gets or sets the number of random samples
(iterations) generated by the algorithm.
 
NumberOfParameters 
Gets the number of parameters expected by
the Function to be integrated.
 
Random 
Gets or sets the random generator algorithm to be used within
this Monte Carlo method.
 
Range 
Gets or sets the range of each input variable
under which the integral must be computed.

Name  Description  

Clone 
Creates a new object that is a copy of the current instance.
 
Compute  
Equals  Determines whether the specified object is equal to the current object. (Inherited from Object.)  
Finalize  Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)  
GetHashCode  Serves as the default hash function. (Inherited from Object.)  
GetType  Gets the Type of the current instance. (Inherited from Object.)  
Integrate(FuncDouble, Double, Double, Double)  
Integrate(FuncDouble, Double, Double, Double, Int32) 
Computes the area under the integral for the given function, in the
given integration interval, using a Monte Carlo integration algorithm.
 
Integrate(FuncDouble, Double, Double, Double, Int32)  
MemberwiseClone  Creates a shallow copy of the current Object. (Inherited from Object.)  
Reset 
Manually resets the previously computed area and error
estimates, so the integral can be computed from scratch
without reusing previous computations.
 
ToString  Returns a string that represents the current object. (Inherited from Object.) 
Name  Description  

HasMethod 
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)  
IsEqual 
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.)  
To(Type)  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)  
ToT  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) 
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 higherdimensional integrals. There are different methods to perform a Monte Carlo integration, such as uniform sampling, stratified sampling and importance sampling.
References:
A common MonteCarlo integration example is to compute the value of Pi. This is the same example given in Wikipedia's page for MonteCarlo Integration, available at https://en.wikipedia.org/wiki/Monte_Carlo_integration#Example
// Define a function H that tells whether two points // are inside a unit circle (a circle of radius one): // Func<double, double, double> H = (x, y) => (x * x + y * y <= 1) ? 1 : 0; // We will check how many points in the square (1,1), (1,+1), // (+1, 1), (+1, +1) fall into the circle defined by function H. // double[] from = { 1, 1 }; double[] to = { +1, +1 }; int samples = 100000; // Integrate it! double area = MonteCarloIntegration.Integrate(x => H(x[0], x[1]), from, to, samples); // Output should be approximately 3.14.