Example usage for org.apache.commons.math.util FastMath PI

List of usage examples for org.apache.commons.math.util FastMath PI

Introduction

In this page you can find the example usage for org.apache.commons.math.util FastMath PI.

Prototype

double PI

To view the source code for org.apache.commons.math.util FastMath PI.

Click Source Link

Document

Archimede's constant PI, ratio of circle circumference to diameter.

Usage

From source file:cz.paulrz.montecarlo.random.Sobol.java

@Override
public double nextGaussian() {
    final double random;
    if (Double.isNaN(nextGaussian)) {
        // generate a new pair of gaussian numbers
        final double[] xs = nextPoint();
        final double x = xs[0];
        final double y = xs[1];
        final double alpha = 2 * FastMath.PI * x;
        final double r = FastMath.sqrt(-2 * FastMath.log(y));
        random = r * FastMath.cos(alpha);
        nextGaussian = r * FastMath.sin(alpha);
    } else {/*  ww  w. j  a v a  2  s .  c  om*/
        // use the second element of the pair already generated
        random = nextGaussian;
        nextGaussian = Double.NaN;
    }

    return random;
}