Example usage for java.lang Float NEGATIVE_INFINITY

List of usage examples for java.lang Float NEGATIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Float NEGATIVE_INFINITY.

Prototype

float NEGATIVE_INFINITY

To view the source code for java.lang Float NEGATIVE_INFINITY.

Click Source Link

Document

A constant holding the negative infinity of type float .

Usage

From source file:nl.uva.illc.dataselection.InvitationModel.java

public static void burnIN() throws IOException, InterruptedException {

    log.info("BurnIN started ... ");

    HashIntObjMap<Result> results = null;

    for (int i = 1; i <= 1; i++) {

        log.info("Iteration " + i);

        results = HashIntObjMaps.newMutableMap();

        float sPD[][] = new float[2][src_mixdomain.length];

        int split = (int) Math.ceil(src_mixdomain.length / 100000d);

        latch = new CountDownLatch(split);
        for (int sent = 0; sent < src_mixdomain.length; sent += 100000) {
            int end = sent + 100000;
            if (end > src_mixdomain.length) {
                end = src_mixdomain.length;
            }// w  ww  .  j  av a2 s.co m
            calcualteBurnInScore(sent, end, sPD);
        }
        latch.await();

        float countPD[] = new float[2];
        countPD[0] = Float.NEGATIVE_INFINITY;
        countPD[1] = Float.NEGATIVE_INFINITY;

        for (int sent = 0; sent < src_mixdomain.length; sent++) {

            if (ignore.containsKey(sent))
                continue;

            if (Float.isNaN(sPD[0][sent]) || Float.isNaN(sPD[1][sent])) {
                ignore.put(sent, sent);
                log.info("Ignoring " + (sent + 1));
                continue;
            }

            countPD[0] = logAdd(countPD[0], sPD[0][sent]);
            countPD[1] = logAdd(countPD[1], sPD[1][sent]);

            results.put(sent, new Result(sent, sPD[0][sent]));

        }

    }

    log.info("BurnIN DONE");

    log.info("Writing outdomain corpus ... ");

    ArrayList<Result> sortedResult = new ArrayList<Result>(results.values());
    Collections.sort(sortedResult);

    PrintWriter src_out = new PrintWriter("outdomain." + SRC + ".encoded");
    PrintWriter trg_out = new PrintWriter("outdomain." + TRG + ".encoded");

    PrintWriter out_score = new PrintWriter("outdomain.scores");

    src_outdomain = new int[src_indomain.length][];
    trg_outdomain = new int[trg_indomain.length][];

    int j = 0;

    for (Result r : sortedResult) {

        int sentIndex = r.sentenceNumber - 1;

        int ssent[] = src_mixdomain[sentIndex];
        int tsent[] = trg_mixdomain[sentIndex];

        out_score.println(r.sentenceNumber + "\t" + r.score);

        src_outdomain[j] = ssent;
        trg_outdomain[j] = tsent;

        for (int w = 1; w < ssent.length; w++) {
            src_out.print(ssent[w]);
            src_out.print(" ");
        }
        src_out.println();
        for (int w = 1; w < tsent.length; w++) {
            trg_out.print(tsent[w]);
            trg_out.print(" ");
        }
        trg_out.println();

        j++;

        if (j == src_indomain.length) {
            break;
        }
    }

    out_score.close();

    src_out.close();
    trg_out.close();

    log.info("DONE");

}

From source file:mase.stat.MasterTournament.java

private void logResults(List<PersistentSolution>[] solutions, List<EvaluationResult[]>[] subpopEvals,
        String outPath) throws Exception {
    // Log results
    File log = new File(outPath + "comp" + name + ".stat");
    BufferedWriter bfw = new BufferedWriter(new FileWriter(log));
    float[] bestFar = new float[] { Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY };
    for (int g = 0; g < subpopEvals[0].size(); g++) {
        bfw.write(g + "");
        for (int s = 0; s < 2; s++) {
            EvaluationResult[] er = subpopEvals[s].get(g);
            // assumes fitness evaluation is in first index
            float fit = (Float) (((CompoundEvaluationResult) er[0]).getEvaluation(s).value());
            // assumes behaviour evaluation is in second index
            BehaviourResult br = null;/* w w w . j av  a 2  s.c  om*/
            if (er[1] instanceof CompoundEvaluationResult) {
                br = (BehaviourResult) ((CompoundEvaluationResult) er[1]).getEvaluation(s);
            } else {
                br = (BehaviourResult) er[1];
            }
            bestFar[s] = Math.max(bestFar[s], fit);
            bfw.write(" " + fit + " " + bestFar[s] + " " + br.toString());
        }
        bfw.newLine();
    }
    bfw.close();

    // Persist the most interesting challenge
    PersistentSolution best0 = solutions[0].get(bestIndex(subpopEvals[0], 0));
    PersistentSolution best1 = solutions[1].get(bestIndex(subpopEvals[1], 1));
    HeterogeneousGroupController hc0 = (HeterogeneousGroupController) best0.getController();
    HeterogeneousGroupController hc1 = (HeterogeneousGroupController) best1.getController();
    HeterogeneousGroupController newC = new HeterogeneousGroupController(
            new AgentController[] { hc0.getAgentControllers(2)[0], hc1.getAgentControllers(2)[1] });
    CompoundEvaluationResult ser = new CompoundEvaluationResult(new FitnessResult(bestFar[0]),
            new FitnessResult(bestFar[1]));
    PersistentSolution sol = new PersistentSolution();
    sol.setController(newC);
    sol.setEvalResults(new EvaluationResult[] { ser });
    File superBest = new File(outPath + "challenge" + name + ".xml");
    SolutionPersistence.writeSolution(sol, superBest);
}

From source file:io.github.gjyaiya.stetho.realm.Database.java

private List<Object> flattenRows(Table table, long limit, boolean addRowIndex) {
    Util.throwIfNot(limit >= 0);
    final List<Object> flatList = new ArrayList<>();
    long numColumns = table.getColumnCount();

    final RowFetcher rowFetcher = RowFetcher.getInstance();
    final long tableSize = table.size();
    for (long index = 0; index < limit && index < tableSize; index++) {
        final long row = ascendingOrder ? index : (tableSize - index - 1);
        final RowWrapper rowData = RowWrapper.wrap(rowFetcher.getRow(table, row));
        if (addRowIndex) {
            flatList.add(rowData.getIndex());
        }/*from   w  w w  .jav a 2  s. co m*/
        for (int column = 0; column < numColumns; column++) {
            switch (rowData.getColumnType(column)) {
            case INTEGER:
                if (rowData.isNull(column)) {
                    flatList.add(NULL);
                } else {
                    flatList.add(rowData.getLong(column));
                }
                break;
            case BOOLEAN:
                if (rowData.isNull(column)) {
                    flatList.add(NULL);
                } else {
                    flatList.add(rowData.getBoolean(column));
                }
                break;
            case STRING:
                if (rowData.isNull(column)) {
                    flatList.add(NULL);
                } else {
                    flatList.add(rowData.getString(column));
                }
                break;
            case BINARY:
                if (rowData.isNull(column)) {
                    flatList.add(NULL);
                } else {
                    flatList.add(rowData.getBinaryByteArray(column));
                }
                break;
            case FLOAT:
                if (rowData.isNull(column)) {
                    flatList.add(NULL);
                } else {
                    final float aFloat = rowData.getFloat(column);
                    if (Float.isNaN(aFloat)) {
                        flatList.add("NaN");
                    } else if (aFloat == Float.POSITIVE_INFINITY) {
                        flatList.add("Infinity");
                    } else if (aFloat == Float.NEGATIVE_INFINITY) {
                        flatList.add("-Infinity");
                    } else {
                        flatList.add(aFloat);
                    }
                }
                break;
            case DOUBLE:
                if (rowData.isNull(column)) {
                    flatList.add(NULL);
                } else {
                    final double aDouble = rowData.getDouble(column);
                    if (Double.isNaN(aDouble)) {
                        flatList.add("NaN");
                    } else if (aDouble == Double.POSITIVE_INFINITY) {
                        flatList.add("Infinity");
                    } else if (aDouble == Double.NEGATIVE_INFINITY) {
                        flatList.add("-Infinity");
                    } else {
                        flatList.add(aDouble);
                    }
                }
                break;
            case OLD_DATE:
            case DATE:
                if (rowData.isNull(column)) {
                    flatList.add(NULL);
                } else {
                    flatList.add(formatDate(rowData.getDate(column)));
                }
                break;
            case OBJECT:
                if (rowData.isNullLink(column)) {
                    flatList.add(NULL);
                } else {
                    flatList.add(rowData.getLink(column));
                }
                break;
            case LIST:
                // LIST never be null
                flatList.add(formatList(rowData.getLinkList(column)));
                break;
            default:
                flatList.add("unknown column type: " + rowData.getColumnType(column));
                break;
            }
        }
    }

    if (limit < table.size()) {
        for (int column = 0; column < numColumns; column++) {
            flatList.add("{truncated}");
        }
    }

    return flatList;
}

From source file:net.sf.json.TestJSONArray.java

public void testConstructor_primitive_array_float_Infinity() {
    try {//  ww w.ja  v a  2 s. c  o  m
        JSONArray.fromObject(new float[] { Float.NEGATIVE_INFINITY });
        fail("Should have thrown a JSONException");
    } catch (JSONException expected) {
        // OK
    }

    try {
        JSONArray.fromObject(new float[] { Float.POSITIVE_INFINITY });
        fail("Should have thrown a JSONException");
    } catch (JSONException expected) {
        // OK
    }
}

From source file:edworld.pdfreader4humans.PDFReader.java

protected Component createGroup(int groupIndex, Map<Component, Integer> groupMap) {
    float fromX = Float.POSITIVE_INFINITY;
    float fromY = Float.POSITIVE_INFINITY;
    float toX = Float.NEGATIVE_INFINITY;
    float toY = Float.NEGATIVE_INFINITY;
    for (Component component : groupMap.keySet())
        if (groupMap.get(component) == groupIndex) {
            fromX = Math.min(component.getFromX(), fromX);
            fromY = Math.min(component.getFromY(), fromY);
            toX = Math.max(component.getToX(), toX);
            toY = Math.max(component.getToY(), toY);
        }//from w  w w . j  a  v  a2 s.c om
    return new GroupComponent(fromX, fromY, toX, toY);
}

From source file:com.cloudera.oryx.als.serving.ServerRecommender.java

private List<IDValue> multithreadedTopN(final float[][] userFeatures, final LongSet userKnownItemIDs,
        final Rescorer rescorer, final int howMany, CandidateFilter candidateFilter) throws NotReadyException {

    Collection<Iterator<LongObjectMap.MapEntry<float[]>>> candidateIterators = candidateFilter
            .getCandidateIterator(userFeatures);

    int numIterators = candidateIterators.size();
    int parallelism = FastMath.min(numCores, numIterators);

    final Queue<NumericIDValue> topN = TopN.initialQueue(howMany);

    if (parallelism > 1) {

        ExecutorService executorService = executor.get();

        final Iterator<Iterator<LongObjectMap.MapEntry<float[]>>> candidateIteratorsIterator = candidateIterators
                .iterator();/*from  ww  w .jav  a  2s.  com*/

        Collection<Future<Object>> futures = Lists.newArrayList();
        for (int i = 0; i < numCores; i++) {
            futures.add(executorService.submit(new Callable<Object>() {
                @Override
                public Void call() throws NotReadyException {
                    float[] queueLeastValue = { Float.NEGATIVE_INFINITY };
                    while (true) {
                        Iterator<LongObjectMap.MapEntry<float[]>> candidateIterator;
                        synchronized (candidateIteratorsIterator) {
                            if (!candidateIteratorsIterator.hasNext()) {
                                break;
                            }
                            candidateIterator = candidateIteratorsIterator.next();
                        }
                        Iterator<NumericIDValue> partialIterator = new RecommendIterator(userFeatures,
                                candidateIterator, userKnownItemIDs, rescorer,
                                getCurrentGeneration().getIDMapping());
                        TopN.selectTopNIntoQueueMultithreaded(topN, queueLeastValue, partialIterator, howMany);
                    }
                    return null;
                }
            }));
        }
        ExecutorUtils.checkExceptions(futures);

    } else {

        for (Iterator<LongObjectMap.MapEntry<float[]>> candidateIterator : candidateIterators) {
            Iterator<NumericIDValue> partialIterator = new RecommendIterator(userFeatures, candidateIterator,
                    userKnownItemIDs, rescorer, getCurrentGeneration().getIDMapping());
            TopN.selectTopNIntoQueue(topN, partialIterator, howMany);
        }

    }

    return translateToStringIDs(TopN.selectTopNFromQueue(topN, howMany));
}

From source file:com.linkedin.pinot.integration.tests.DefaultColumnsClusterIntegrationTest.java

@Test
public void testNewAddedColumns() throws Exception {
    String pqlQuery;/*from w w w  .  j  av  a2  s . c om*/
    String sqlQuery;

    // Test queries with each new added columns.
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedIntMetric = 1";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedLongMetric = 1";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedFloatMetric = 0.0";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedDoubleMetric = 0.0";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedIntDimension < 0";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedLongDimension < 0";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedFloatDimension < 0.0";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedDoubleDimension < 0.0";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedStringDimension = 'newAdded'";
    sqlQuery = "SELECT COUNT(*) FROM mytable";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));

    // Test queries with new added metric column in aggregation function.
    pqlQuery = "SELECT SUM(NewAddedIntMetric) FROM mytable WHERE DaysSinceEpoch <= 16312";
    sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch <= 16312";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT SUM(NewAddedIntMetric) FROM mytable WHERE DaysSinceEpoch > 16312";
    sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch > 16312";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT SUM(NewAddedLongMetric) FROM mytable WHERE DaysSinceEpoch <= 16312";
    sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch <= 16312";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));
    pqlQuery = "SELECT SUM(NewAddedLongMetric) FROM mytable WHERE DaysSinceEpoch > 16312";
    sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch > 16312";
    runQuery(pqlQuery, Collections.singletonList(sqlQuery));

    // Test other query forms with new added columns.
    JSONObject response;
    JSONObject groupByResult;
    pqlQuery = "SELECT SUM(NewAddedFloatMetric) FROM mytable GROUP BY NewAddedStringDimension";
    response = postQuery(pqlQuery);
    groupByResult = response.getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult")
            .getJSONObject(0);
    Assert.assertEquals(groupByResult.getInt("value"), 0);
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), "newAdded");
    pqlQuery = "SELECT SUM(NewAddedDoubleMetric) FROM mytable GROUP BY NewAddedIntDimension";
    response = postQuery(pqlQuery);
    groupByResult = response.getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult")
            .getJSONObject(0);
    Assert.assertEquals(groupByResult.getInt("value"), 0);
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE));
    pqlQuery = "SELECT SUM(NewAddedIntMetric) FROM mytable GROUP BY NewAddedLongDimension";
    response = postQuery(pqlQuery);
    groupByResult = response.getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult")
            .getJSONObject(0);
    Assert.assertEquals(groupByResult.getInt("value"), TOTAL_DOCS);
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Long.MIN_VALUE));
    pqlQuery = "SELECT SUM(NewAddedIntMetric), SUM(NewAddedLongMetric), SUM(NewAddedFloatMetric), SUM(NewAddedDoubleMetric) "
            + "FROM mytable GROUP BY NewAddedIntDimension, NewAddedLongDimension, NewAddedFloatDimension, "
            + "NewAddedDoubleDimension, NewAddedStringDimension";
    response = postQuery(pqlQuery);
    JSONArray groupByResultArray = response.getJSONArray("aggregationResults");
    groupByResult = groupByResultArray.getJSONObject(0).getJSONArray("groupByResult").getJSONObject(0);
    Assert.assertEquals(groupByResult.getInt("value"), TOTAL_DOCS);
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(2),
            String.valueOf(Float.NEGATIVE_INFINITY));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(3),
            String.valueOf(Double.NEGATIVE_INFINITY));
    groupByResult = groupByResultArray.getJSONObject(1).getJSONArray("groupByResult").getJSONObject(0);
    Assert.assertEquals(groupByResult.getInt("value"), TOTAL_DOCS);
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(2),
            String.valueOf(Float.NEGATIVE_INFINITY));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(3),
            String.valueOf(Double.NEGATIVE_INFINITY));
    groupByResult = groupByResultArray.getJSONObject(2).getJSONArray("groupByResult").getJSONObject(0);
    Assert.assertEquals(groupByResult.getInt("value"), 0);
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(2),
            String.valueOf(Float.NEGATIVE_INFINITY));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(3),
            String.valueOf(Double.NEGATIVE_INFINITY));
    groupByResult = groupByResultArray.getJSONObject(3).getJSONArray("groupByResult").getJSONObject(0);
    Assert.assertEquals(groupByResult.getInt("value"), 0);
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(2),
            String.valueOf(Float.NEGATIVE_INFINITY));
    Assert.assertEquals(groupByResult.getJSONArray("group").getString(3),
            String.valueOf(Double.NEGATIVE_INFINITY));
    pqlQuery = "SELECT * FROM mytable";
    runQuery(pqlQuery, null);
}

From source file:hu.ppke.itk.nlpg.purepos.decoder.AbstractDecoder.java

private Map<NGram<Integer>, Map<Integer, Pair<Double, Double>>> getNextForSingleTaggedToken(
        final Set<NGram<Integer>> prevTagsSet, Collection<Integer> anals) {
    Map<NGram<Integer>, Map<Integer, Pair<Double, Double>>> ret = new HashMap<NGram<Integer>, Map<Integer, Pair<Double, Double>>>();
    for (NGram<Integer> prevTags : prevTagsSet) {
        Map<Integer, Pair<Double, Double>> tagProbs = new HashMap<Integer, Pair<Double, Double>>();
        Integer tag = anals.iterator().next();
        Double tagProb = model.getTagTransitionModel().getLogProb(prevTags.toList(), tag);
        tagProb = tagProb == Float.NEGATIVE_INFINITY ? 0 : tagProb;
        tagProbs.put(tag, new ImmutablePair<Double, Double>(tagProb, 0.0));
        ret.put(prevTags, tagProbs);//w w  w .  j  a  v a2 s  .  c o  m
    }
    return ret;
}

From source file:nl.uva.illc.dataselection.InvitationModel.java

public static void training() throws FileNotFoundException, InterruptedException {

    log.info("Starting Invitation EM ...");

    latch = new CountDownLatch(2);
    ttable[2] = new TranslationTable();
    ttable[3] = new TranslationTable();
    initializeTranslationTable(src_outdomain, trg_outdomain, ttable[2]);
    initializeTranslationTable(trg_outdomain, src_outdomain, ttable[3]);
    latch.await();/*from www  .  j av  a 2  s  .co m*/

    for (int i = 1; i <= iMAX; i++) {
        log.info("Iteration " + i);
        HashIntObjMap<Result> results = HashIntObjMaps.newMutableMap();

        float sPD[][] = new float[2][src_mixdomain.length];

        int splits = 10;
        int split_size = src_mixdomain.length / splits;

        latch = new CountDownLatch(splits);
        for (int s = 0; s < splits; s++) {
            int start = s * split_size;
            int end = start + split_size;
            if (s == (splits - 1)) {
                end = src_mixdomain.length;
            }
            calcualteScore(start, end, sPD);
        }
        latch.await();

        float countPD[] = new float[2];
        countPD[0] = Float.NEGATIVE_INFINITY;
        countPD[1] = Float.NEGATIVE_INFINITY;

        for (int sent = 0; sent < src_mixdomain.length; sent++) {

            if (ignore.containsKey(sent))
                continue;

            if (Float.isNaN(sPD[0][sent]) || Float.isNaN(sPD[1][sent])) {
                ignore.put(sent, sent);
                log.info("Ignoring " + (sent + 1));
                continue;
            }

            countPD[0] = logAdd(countPD[0], sPD[0][sent]);
            countPD[1] = logAdd(countPD[1], sPD[1][sent]);

            float srcP = lm[0][sent];
            float trgP = lm[1][sent];
            results.put(sent, new Result(sent, sPD[1][sent], srcP + trgP));

        }

        float newPD1 = countPD[1] - logAdd(countPD[0], countPD[1]);
        float newPD0 = countPD[0] - logAdd(countPD[0], countPD[1]);

        log.info("PD1 ~ PD0 " + Math.exp(newPD1) + " ~ " + Math.exp(newPD0));

        writeResult(i, results);

        if (i > 1 && Math.abs(Math.exp(newPD1) - Math.exp(PD1)) <= CONV_THRESHOLD) {
            log.info("Convergence threshold reached.");
            break;
        }

        PD1 = newPD1;
        PD0 = newPD0;

        if (i < iMAX) {

            latch = new CountDownLatch(4);
            updateTranslationTable(src_mixdomain, trg_mixdomain, ttable[0], sPD[1]);
            updateTranslationTable(trg_mixdomain, src_mixdomain, ttable[1], sPD[1]);
            updateTranslationTable(src_mixdomain, trg_mixdomain, ttable[2], sPD[0]);
            updateTranslationTable(trg_mixdomain, src_mixdomain, ttable[3], sPD[0]);
            latch.await();
        }

    }
}

From source file:gdsc.core.ij.Utils.java

/**
 * Calculate a histogram given the provided data
 * //from www.ja va2  s  .  c  o  m
 * @param data
 * @param numBins
 *            The number of histogram bins between min and max
 * @return The histogram as a pair of arrays: { value[], frequency[] }
 */
public static float[][] calcHistogram(float[] data, int numBins) {
    float min = Float.POSITIVE_INFINITY;
    float max = Float.NEGATIVE_INFINITY;
    for (float f : data) {
        if (min > f)
            min = f;
        if (max < f)
            max = f;
    }
    return calcHistogram(data, min, max, numBins);
}