Example usage for java.lang Double MIN_EXPONENT

List of usage examples for java.lang Double MIN_EXPONENT

Introduction

In this page you can find the example usage for java.lang Double MIN_EXPONENT.

Prototype

int MIN_EXPONENT

To view the source code for java.lang Double MIN_EXPONENT.

Click Source Link

Document

Minimum exponent a normalized double variable may have.

Usage

From source file:Main.java

public static void main(String[] args) {

    System.out.println(Double.MIN_EXPONENT);
}

From source file:org.amanzi.neo.models.impl.network.NetworkModelTest.java

@Test
public void testCheckGetElement() throws ModelException {
    Envelope env = new Envelope(Double.MIN_EXPONENT, Double.MAX_EXPONENT, Double.MIN_NORMAL, Double.MAX_VALUE);
    List<Node> nodes = new ArrayList<Node>();
    Map<String, Object> properties = getProperties();
    properties.put(GEO_NODE_PROPERTIES.getLatitudeProperty(), Double.MIN_VALUE);
    properties.put(GEO_NODE_PROPERTIES.getLongitudeProperty(), Double.MAX_VALUE);
    Node mockedNode = getNodeMock(properties);
    nodes.add(mockedNode);//from  w w  w . j a v  a  2 s .  co m
    Double[] min = new Double[] { env.getMinY(), env.getMinX() };
    Double[] max = new Double[] { env.getMaxY(), env.getMaxX() };
    doReturn(nodes.iterator()).when(indexModel).getNodes(NetworkElementType.SITE, Double.class, min, max,
            GEO_NODE_PROPERTIES.getLatitudeProperty(), GEO_NODE_PROPERTIES.getLongitudeProperty());

}

From source file:org.renjin.primitives.random.ChiSquare.java

public static double pnchisq_raw(double x, double f, double theta, double errmax, double reltol, int itrmax,
        boolean lower_tail) {
    double lam, x2, f2, term, bound, f_x_2n, f_2n;
    double l_lam = -1., l_x = -1.; /* initialized for -Wall */
    int n;/*from  w ww.  ja  va 2s. c  om*/
    boolean lamSml, tSml, is_r, is_b, is_it;
    double ans, u, v, t, lt, lu = -1;

    final double _dbl_min_exp = Math.log(2) * Double.MIN_EXPONENT;
    /*= -708.3964 for IEEE double precision */

    if (x <= 0.) {
        if (x == 0. && f == 0.) {
            return lower_tail ? Math.exp(-0.5 * theta) : -Math.expm1(-0.5 * theta);
        }
        /* x < 0  or {x==0, f > 0} */
        return lower_tail ? 0. : 1.;
    }
    if (!DoubleVector.isFinite(x)) {
        return lower_tail ? 1. : 0.;
    }

    if (theta < 80) { /* use 110 for Inf, as ppois(110, 80/2, lower.tail=FALSE) is 2e-20 */
        double sum = 0, sum2 = 0, lambda = 0.5 * theta, pr = Math.exp(-lambda);
        double ans_inner;
        int i;
        /* we need to renormalize here: the result could be very close to 1 */
        for (i = 0; i < 110; pr *= lambda / ++i) {
            sum2 += pr;
            sum += pr * Distributions.pchisq(x, f + 2 * i, lower_tail, false);
            if (sum2 >= 1 - 1e-15) {
                break;
            }
        }
        ans_inner = sum / sum2;
        return ans_inner;
    }

    lam = .5 * theta;
    lamSml = (-lam < _dbl_min_exp);
    if (lamSml) {
        /* MATHLIB_ERROR(
        "non centrality parameter (= %g) too large for current algorithm",
        theta) */
        u = 0;
        lu = -lam;/* == ln(u) */
        l_lam = Math.log(lam);
    } else {
        u = Math.exp(-lam);
    }

    /* evaluate the first term */
    v = u;
    x2 = .5 * x;
    f2 = .5 * f;
    f_x_2n = f - x;

    if (f2 * SignRank.DBL_EPSILON > 0.125 && /* very large f and x ~= f: probably needs */ Math
            .abs(t = x2 - f2) < /* another algorithm anyway */ Math.sqrt(SignRank.DBL_EPSILON) * f2) {
        /* evade cancellation error */
        /* t = exp((1 - t)*(2 - t/(f2 + 1))) / sqrt(2*M_PI*(f2 + 1));*/
        lt = (1 - t) * (2 - t / (f2 + 1)) - 0.5 * Math.log(2 * Math.PI * (f2 + 1));
    } else {
        /* Usual case 2: careful not to overflow .. : */
        lt = f2 * Math.log(x2) - x2 - org.apache.commons.math.special.Gamma.logGamma(f2 + 1);
    }

    tSml = (lt < _dbl_min_exp);
    if (tSml) {
        if (x > f + theta + 5 * Math.sqrt(2 * (f + 2 * theta))) {
            /* x > E[X] + 5* sigma(X) */
            return lower_tail ? 1. : 0.; /* FIXME: We could be more accurate than 0. */
        } /* else */
        l_x = Math.log(x);
        ans = term = t = 0.;
    } else {
        t = Math.exp(lt);
        ans = term = v * t;
    }

    for (n = 1, f_2n = f + 2., f_x_2n += 2.;; n++, f_2n += 2, f_x_2n += 2) {
        /* f_2n    === f + 2*n
         * f_x_2n  === f - x + 2*n   > 0  <==> (f+2n)  >   x */
        if (f_x_2n > 0) {
            /* find the error bound and check for convergence */

            bound = t * x / f_x_2n;
            is_r = is_it = false;
            /* convergence only if BOTH absolute and relative error < 'bnd' */
            if (((is_b = (bound <= errmax)) && (is_r = (term <= reltol * ans))) || (is_it = (n > itrmax))) {
                break; /* out completely */
            }

        }

        /* evaluate the next term of the */
        /* expansion and then the partial sum */

        if (lamSml) {
            lu += l_lam - Math.log(n); /* u = u* lam / n */
            if (lu >= _dbl_min_exp) {
                /* no underflow anymore ==> change regime */
                v = u = Math.exp(lu); /* the first non-0 'u' */
                lamSml = false;
            }
        } else {
            u *= lam / n;
            v += u;
        }
        if (tSml) {
            lt += l_x - Math.log(f_2n);/* t <- t * (x / f2n) */
            if (lt >= _dbl_min_exp) {
                /* no underflow anymore ==> change regime */

                t = Math.exp(lt); /* the first non-0 't' */
                tSml = false;
            }
        } else {
            t *= x / f_2n;
        }
        if (!lamSml && !tSml) {
            term = v * t;
            ans += term;
        }

    } /* for(n ...) */

    if (is_it) {
        // How to alert this message without an exception?
        //(_("pnchisq(x=%g, ..): not converged in %d iter."),x, itrmax);
    }
    return lower_tail ? ans : 1 - ans;
}