Example usage for java.lang Double MIN_NORMAL

List of usage examples for java.lang Double MIN_NORMAL

Introduction

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

Prototype

double MIN_NORMAL

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

Click Source Link

Document

A constant holding the smallest positive normal value of type double , 2-1022.

Usage

From source file:Main.java

public static void main(String[] args) {

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

From source file:Main.java

/**
 * Fills the array with random doubles.  Values will be between min (inclusive) and
 * max (inclusive)./* w w  w .j a  va 2  s  . c  om*/
 */
public static void genRandomDoubles(long seed, double min, double max, double array[],
        boolean includeExtremes) {
    Random r = new Random(seed);
    int minExponent = Math.min(Math.getExponent(min), 0);
    int maxExponent = Math.max(Math.getExponent(max), 0);
    if (minExponent < -6 || maxExponent > 6) {
        // Use an exponential distribution
        int exponentDiff = maxExponent - minExponent;
        for (int i = 0; i < array.length; i++) {
            double mantissa = r.nextDouble();
            int exponent = minExponent + r.nextInt(maxExponent - minExponent);
            int sign = (min >= 0) ? 1 : 1 - r.nextInt(2) * 2; // -1 or 1
            double rand = sign * mantissa * Math.pow(2.0, exponent);
            if (rand < min || rand > max) {
                continue;
            }
            array[i] = rand;
        }
    } else {
        // Use a linear distribution
        for (int i = 0; i < array.length; i++) {
            double rand = r.nextDouble();
            array[i] = min + rand * (max - min);
        }
    }
    // Seed a few special numbers we want to be sure to test.
    for (int i = 0; i < sInterestingDoubles.length; i++) {
        double d = sInterestingDoubles[i];
        if (min <= d && d <= max) {
            array[r.nextInt(array.length)] = d;
        }
    }
    array[r.nextInt(array.length)] = min;
    array[r.nextInt(array.length)] = max;
    if (includeExtremes) {
        array[r.nextInt(array.length)] = Double.NaN;
        array[r.nextInt(array.length)] = Double.POSITIVE_INFINITY;
        array[r.nextInt(array.length)] = Double.NEGATIVE_INFINITY;
        array[r.nextInt(array.length)] = Double.MIN_VALUE;
        array[r.nextInt(array.length)] = Double.MIN_NORMAL;
        array[r.nextInt(array.length)] = Double.MAX_VALUE;
        array[r.nextInt(array.length)] = -Double.MIN_VALUE;
        array[r.nextInt(array.length)] = -Double.MIN_NORMAL;
        array[r.nextInt(array.length)] = -Double.MAX_VALUE;
    }
}

From source file:de.huberlin.wbi.hiway.scheduler.WienerProcessModel.java

public double getEstimate(double timestamp, double alpha) {
    if (alpha == 0.5 && measurements.size() > 0) {
        return logarithmize ? Math.pow(Math.E, measurements.getLast().runtime)
                : Math.max(measurements.getLast().runtime, Double.MIN_NORMAL);
    }//from www  .java 2s  . c  o  m

    if (differences.size() < 2) {
        return 0d;
    }

    Runtime lastMeasurement = measurements.getLast();

    double variance = 0d;
    double avgDifference = sumOfDifferences / differences.size();
    for (double difference : differences) {
        variance += Math.pow(difference - avgDifference, 2d);
    }
    variance /= differences.size() - 1;

    variance *= timestamp - lastMeasurement.timestamp;

    double estimate = lastMeasurement.runtime;
    if (variance > 0d) {
        NormalDistribution nd = new NormalDistribution(lastMeasurement.runtime, Math.sqrt(variance));
        estimate = nd.inverseCumulativeProbability(alpha);
    }

    estimate = logarithmize ? Math.pow(Math.E, estimate) : Math.max(estimate, 0d);

    return estimate;
}

From source file:com.cloud2bubble.services.FuzzyEngine.java

private String evaluateForTerm(Cloudlet c, Bubble b) {
    Double temp = Double.MIN_NORMAL;
    String term = null;/*from  ww w  .  j  a  va 2 s . c  om*/

    // load profile vars
    fis.setVariable(PROFILE_TEMP_COLD_MEAN, b.getProfile().get(PROFILE_TEMP_COLD_MEAN));
    fis.setVariable(PROFILE_TEMP_COLD_STD, b.getProfile().get(PROFILE_TEMP_COLD_STD));
    fis.setVariable(PROFILE_TEMP_WARM_MEAN, b.getProfile().get(PROFILE_TEMP_WARM_MEAN));
    fis.setVariable(PROFILE_TEMP_WARM_STD, b.getProfile().get(PROFILE_TEMP_WARM_STD));
    fis.setVariable(PROFILE_TEMP_HOT_MEAN, b.getProfile().get(PROFILE_TEMP_HOT_MEAN));
    fis.setVariable(PROFILE_TEMP_HOT_STD, b.getProfile().get(PROFILE_TEMP_HOT_STD));

    // load env vars
    if (c.getEnvironment().get(Environment.TEMPERATURE) != null) {
        fis.setVariable(Environment.TEMPERATURE.toString().toLowerCase(),
                Double.valueOf(c.getEnvironment().get(Environment.TEMPERATURE)));
    } else {
        fis.setVariable(Environment.TEMPERATURE.toString().toLowerCase(), Double.NaN);
    }

    fis.evaluate();

    for (String functionTerm : fis.getVariable(QualityOfExperience.FUNCTION).getLinguisticTerms().keySet()) {
        if (fis.getVariable(QualityOfExperience.FUNCTION).getMembership(functionTerm) > temp) {
            term = functionTerm;
            temp = fis.getVariable(QualityOfExperience.FUNCTION).getMembership(functionTerm);
        }
    }

    return term;
}

From source file:emlab.domain.factory.ElectricityProducerFactory.java

private void createPowerPlantsForMarket(ElectricitySpotMarket market) {

    double maxLoad = Double.MIN_NORMAL;
    // get max load
    for (SegmentLoad segmentLoad : market.getLoadDurationCurve()) {

        if (maxLoad < segmentLoad.getBaseLoad()) {
            maxLoad = segmentLoad.getBaseLoad();
        }/* w  ww  .  jav  a 2 s  .  c  o  m*/
    }
    double requiredCapacity = maxLoad * (1 + capacityMargin);
    logger.info("required capacity for market {} is {}", market, requiredCapacity);
    for (PowerGeneratingTechnology technology : portfolioShares.keySet()) {
        double pctValue = portfolioShares.get(technology);
        double requiredCapacityForTechnology = pctValue * requiredCapacity;
        logger.info("required capacity within this market for technology {} is {}", technology,
                requiredCapacityForTechnology);
        // logger.info("required capacity: {} for technology {} before creating",
        // requiredCapacityForTechnology, technology);
        while (requiredCapacityForTechnology > 0) {
            EnergyProducer energyProducer = getRandomProducer(producers);
            PowerPlant plant = createPowerPlant(technology, energyProducer, getNodeForZone(market.getZone()));
            requiredCapacityForTechnology -= plant.getAvailableCapacity(0);
        }
        // logger.info("required capacity: {} for technology {} after creating",
        // requiredCapacityForTechnology, technology);
    }

}

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

@Test(expected = ParameterInconsistencyException.class)
public void testCheckCreateSiteIfLatIsNull() throws ModelException {
    parentElement = new DataElement(getNodeMock());

    Map<String, Object> properties = getProperties();
    properties.put(GENERAL_NODE_PROPERTIES.getNodeNameProperty(), DEFAULT_ELEMENT_NAME);

    networkModel.createSite(parentElement, DEFAULT_ELEMENT_NAME, null, Double.MIN_NORMAL, properties);
}

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

@Test(expected = ParameterInconsistencyException.class)
public void testCheckCreateSiteIfLonIsNull() throws ModelException {
    parentElement = new DataElement(getNodeMock());
    Map<String, Object> properties = getProperties();
    properties.put(GENERAL_NODE_PROPERTIES.getNodeNameProperty(), DEFAULT_ELEMENT_NAME);

    networkModel.createSite(parentElement, DEFAULT_ELEMENT_NAME, Double.MIN_NORMAL, null, properties);
}

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);//www  .  j  av a2s .c om
    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.apache.nifi.util.orc.TestOrcUtils.java

@Test
public void test_putRowToBatch() {
    TypeDescription orcSchema = buildPrimitiveOrcSchema();
    VectorizedRowBatch batch = orcSchema.createRowBatch();
    Schema avroSchema = buildPrimitiveAvroSchema();
    List<Schema.Field> fields = avroSchema.getFields();
    GenericData.Record record = buildPrimitiveAvroRecord(1, 2L, false, 1.0f, 3.0,
            ByteBuffer.wrap("Hello".getBytes()), "World");
    for (int i = 0; i < fields.size(); i++) {
        OrcUtils.putToRowBatch(batch.cols[i], new MutableInt(0), 0, fields.get(i).schema(), record.get(i));
    }/*from w w w . j  a  va  2  s.  co  m*/

    assertEquals(1, ((LongColumnVector) batch.cols[0]).vector[0]);
    assertEquals(2, ((LongColumnVector) batch.cols[1]).vector[0]);
    assertEquals(0, ((LongColumnVector) batch.cols[2]).vector[0]);
    assertEquals(1.0, ((DoubleColumnVector) batch.cols[3]).vector[0], Double.MIN_NORMAL);
    assertEquals(3.0, ((DoubleColumnVector) batch.cols[4]).vector[0], Double.MIN_NORMAL);
    assertEquals("Hello", ((BytesColumnVector) batch.cols[5]).toString(0));
    assertEquals("World", ((BytesColumnVector) batch.cols[6]).toString(0));

}

From source file:org.apache.nifi.util.orc.TestOrcUtils.java

@Test
public void test_putRowToBatch_union() {
    final SchemaBuilder.FieldAssembler<Schema> builder = SchemaBuilder.record("testRecord")
            .namespace("any.data").fields();
    builder.name("union").type().unionOf().intType().and().floatType().endUnion().noDefault();
    Schema testSchema = builder.endRecord();

    GenericData.Record row = new GenericData.Record(testSchema);
    row.put("union", 2);

    TypeDescription orcSchema = TypeDescription.createUnion().addUnionChild(TypeDescription.createInt())
            .addUnionChild(TypeDescription.createFloat());

    VectorizedRowBatch batch = orcSchema.createRowBatch();
    batch.ensureSize(2);//from  w  w w .  j a v a2  s. co m
    OrcUtils.putToRowBatch(batch.cols[0], new MutableInt(0), 0, testSchema.getField("union").schema(),
            row.get("union"));

    UnionColumnVector union = ((UnionColumnVector) batch.cols[0]);
    // verify the value is in the union field of type 'int'
    assertEquals(2, ((LongColumnVector) union.fields[0]).vector[0]);
    assertEquals(0.0, ((DoubleColumnVector) union.fields[1]).vector[0], Double.MIN_NORMAL);

    row.put("union", 2.0f);
    OrcUtils.putToRowBatch(batch.cols[0], new MutableInt(0), 1, testSchema.getField("union").schema(),
            row.get("union"));

    union = ((UnionColumnVector) batch.cols[0]);
    // verify the value is in the union field of type 'double'
    assertEquals(0, ((LongColumnVector) union.fields[0]).vector[1]);
    assertEquals(2.0, ((DoubleColumnVector) union.fields[1]).vector[1], Double.MIN_NORMAL);
}