Class MonteCarloIntegration
- java.lang.Object
-
- org.apache.commons.rng.examples.quadrature.MonteCarloIntegration
-
- Direct Known Subclasses:
ComputePi
public abstract class MonteCarloIntegration extends Object
Monte-Carlo method for approximating an integral on a n-dimensional unit cube.
-
-
Constructor Summary
Constructors Constructor Description MonteCarloIntegration(org.apache.commons.rng.UniformRandomProvider rng, int dimension)
Simulation constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description double
integrate(long n)
Run the Monte-Carlo integration.protected abstract boolean
isInside(double... point)
Indicates whether the given points is inside the region whose integral is computed.
-
-
-
Constructor Detail
-
MonteCarloIntegration
public MonteCarloIntegration(org.apache.commons.rng.UniformRandomProvider rng, int dimension)
Simulation constructor.- Parameters:
rng
- RNG.dimension
- Integration domain dimension.
-
-
Method Detail
-
integrate
public double integrate(long n)
Run the Monte-Carlo integration.- Parameters:
n
- Number of random points to generate.- Returns:
- the integral.
-
isInside
protected abstract boolean isInside(double... point)
Indicates whether the given points is inside the region whose integral is computed.- Parameters:
point
- Point whose coordinates are random numbers uniformly distributed in the unit interval.- Returns:
true
if thepoint
is inside.
-
-