public class ComputePi extends MonteCarloIntegration
Constructor | Description |
---|---|
ComputePi(org.apache.commons.rng.simple.RandomSource source) |
Modifier and Type | Method | Description |
---|---|---|
double |
compute(long numPoints) |
|
protected boolean |
isInside(double... rand) |
Indicates whether the given points is inside the region whose
integral is computed.
|
static void |
main(String[] args) |
Program entry point.
|
integrate
public ComputePi(org.apache.commons.rng.simple.RandomSource source)
source
- RNG algorithm.public static void main(String[] args)
args
- Arguments.
The order is as follows:
Random source identifier
.
public double compute(long numPoints)
numPoints
- Number of random points to generate.protected boolean isInside(double... rand)
isInside
in class MonteCarloIntegration
rand
- Point whose coordinates are random numbers uniformly
distributed in the unit interval.true
if the point
is inside.Copyright © 2016–2018 The Apache Software Foundation. All rights reserved.