Example usage for java.lang Double MIN_VALUE

List of usage examples for java.lang Double MIN_VALUE

Introduction

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

Prototype

double MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type double , 2-1074.

Usage

From source file:org.uma.jmetal.util.experiment.component.GenerateLatexTablesWithStatistics.java

private void printData(String latexFile, int indicatorIndex, double[][][] centralTendency,
        double[][][] dispersion, String caption) throws IOException {
    // Generate header of the table
    FileWriter os = new FileWriter(latexFile, true);
    os.write("\n");
    os.write("\\begin{table}" + "\n");
    os.write("\\caption{" + experiment.getIndicatorList().get(indicatorIndex).getName() + ". " + caption + "}"
            + "\n");
    os.write("\\label{table: " + experiment.getIndicatorList().get(indicatorIndex).getName() + "}" + "\n");
    os.write("\\centering" + "\n");
    os.write("\\begin{scriptsize}" + "\n");
    os.write("\\begin{tabular}{l");

    // calculate the number of columns
    for (TaggedAlgorithm<?> algorithm : experiment.getAlgorithmList()) {
        os.write("l");
    }//from w ww. ja  v a  2  s . c  o m
    os.write("}\n");
    os.write("\\hline");

    // write table head
    for (int i = -1; i < experiment.getAlgorithmList().size(); i++) {
        if (i == -1) {
            os.write(" & ");
        } else if (i == (experiment.getAlgorithmList().size() - 1)) {
            os.write(" " + experiment.getAlgorithmList().get(i).getTag() + "\\\\" + "\n");
        } else {
            os.write("" + experiment.getAlgorithmList().get(i).getTag() + " & ");
        }
    }
    os.write("\\hline \n");

    // write lines
    for (int i = 0; i < experiment.getProblemList().size(); i++) {
        // find the best value and second best value
        double bestCentralTendencyValue;
        double bestDispersionValue;
        double secondBestCentralTendencyValue;
        double secondBestDispersionValue;
        int bestIndex = -1;
        int secondBestIndex = -1;

        if (experiment.getIndicatorList().get(indicatorIndex).isTheLowerTheIndicatorValueTheBetter()) {
            bestCentralTendencyValue = Double.MAX_VALUE;
            bestDispersionValue = Double.MAX_VALUE;
            secondBestCentralTendencyValue = Double.MAX_VALUE;
            secondBestDispersionValue = Double.MAX_VALUE;
            for (int j = 0; j < (experiment.getAlgorithmList().size()); j++) {
                if ((centralTendency[indicatorIndex][i][j] < bestCentralTendencyValue)
                        || ((centralTendency[indicatorIndex][i][j] == bestCentralTendencyValue)
                                && (dispersion[indicatorIndex][i][j] < bestDispersionValue))) {
                    secondBestIndex = bestIndex;
                    secondBestCentralTendencyValue = bestCentralTendencyValue;
                    secondBestDispersionValue = bestDispersionValue;
                    bestCentralTendencyValue = centralTendency[indicatorIndex][i][j];
                    bestDispersionValue = dispersion[indicatorIndex][i][j];
                    bestIndex = j;
                } else if ((centralTendency[indicatorIndex][i][j] < secondBestCentralTendencyValue)
                        || ((centralTendency[indicatorIndex][i][j] == secondBestCentralTendencyValue)
                                && (dispersion[indicatorIndex][i][j] < secondBestDispersionValue))) {
                    secondBestIndex = j;
                    secondBestCentralTendencyValue = centralTendency[indicatorIndex][i][j];
                    secondBestDispersionValue = dispersion[indicatorIndex][i][j];
                }
            }
        } else {
            bestCentralTendencyValue = Double.MIN_VALUE;
            bestDispersionValue = Double.MIN_VALUE;
            secondBestCentralTendencyValue = Double.MIN_VALUE;
            secondBestDispersionValue = Double.MIN_VALUE;
            for (int j = 0; j < (experiment.getAlgorithmList().size()); j++) {
                if ((centralTendency[indicatorIndex][i][j] > bestCentralTendencyValue)
                        || ((centralTendency[indicatorIndex][i][j] == bestCentralTendencyValue)
                                && (dispersion[indicatorIndex][i][j] < bestDispersionValue))) {
                    secondBestIndex = bestIndex;
                    secondBestCentralTendencyValue = bestCentralTendencyValue;
                    secondBestDispersionValue = bestDispersionValue;
                    bestCentralTendencyValue = centralTendency[indicatorIndex][i][j];
                    bestDispersionValue = dispersion[indicatorIndex][i][j];
                    bestIndex = j;
                } else if ((centralTendency[indicatorIndex][i][j] > secondBestCentralTendencyValue)
                        || ((centralTendency[indicatorIndex][i][j] == secondBestCentralTendencyValue)
                                && (dispersion[indicatorIndex][i][j] < secondBestDispersionValue))) {
                    secondBestIndex = j;
                    secondBestCentralTendencyValue = centralTendency[indicatorIndex][i][j];
                    secondBestDispersionValue = dispersion[indicatorIndex][i][j];
                }
            }
        }

        os.write(experiment.getProblemList().get(i).getName().replace("_", "\\_") + " & ");
        for (int j = 0; j < (experiment.getAlgorithmList().size() - 1); j++) {
            if (j == bestIndex) {
                os.write("\\cellcolor{gray95}");
            }
            if (j == secondBestIndex) {
                os.write("\\cellcolor{gray25}");
            }

            String m = String.format(Locale.ENGLISH, "%10.2e", centralTendency[indicatorIndex][i][j]);
            String s = String.format(Locale.ENGLISH, "%8.1e", dispersion[indicatorIndex][i][j]);
            os.write("$" + m + "_{" + s + "}$ & ");
        }
        if (bestIndex == (experiment.getAlgorithmList().size() - 1)) {
            os.write("\\cellcolor{gray95}");
        }
        if (secondBestIndex == (experiment.getAlgorithmList().size() - 1)) {
            os.write("\\cellcolor{gray25}");
        }
        String m = String.format(Locale.ENGLISH, "%10.2e",
                centralTendency[indicatorIndex][i][experiment.getAlgorithmList().size() - 1]);
        String s = String.format(Locale.ENGLISH, "%8.1e",
                dispersion[indicatorIndex][i][experiment.getAlgorithmList().size() - 1]);
        os.write("$" + m + "_{" + s + "}$ \\\\" + "\n");
    }

    // close table
    os.write("\\hline" + "\n");
    os.write("\\end{tabular}" + "\n");
    os.write("\\end{scriptsize}" + "\n");
    os.write("\\end{table}" + "\n");
    os.close();
}

From source file:hivemall.topicmodel.OnlineLDAModel.java

/**
 * Estimates the variational bound over all documents using only the documents passed as
 * mini-batch./*from   ww  w  .ja  va 2  s.  c  om*/
 */
private double computeApproxBound() {
    // prepare
    final double[] gammaSum = new double[_miniBatchSize];
    for (int d = 0; d < _miniBatchSize; d++) {
        gammaSum[d] = MathUtils.sum(_gamma[d]);
    }
    final double[] digamma_gammaSum = MathUtils.digamma(gammaSum);

    final double[] lambdaSum = new double[_K];
    for (float[] lambda_label : _lambda.values()) {
        MathUtils.add(lambda_label, lambdaSum, _K);
    }
    final double[] digamma_lambdaSum = MathUtils.digamma(lambdaSum);

    final double logGamma_alpha = Gamma.logGamma(_alpha);
    final double logGamma_alphaSum = Gamma.logGamma(_K * _alpha);

    double score = 0.d;
    for (int d = 0; d < _miniBatchSize; d++) {
        final double digamma_gammaSum_d = digamma_gammaSum[d];
        final float[] gamma_d = _gamma[d];

        // E[log p(doc | theta, beta)]
        for (Map.Entry<String, Float> e : _miniBatchDocs.get(d).entrySet()) {
            final float[] lambda_label = _lambda.get(e.getKey());

            // logsumexp( Elogthetad + Elogbetad )
            final double[] temp = new double[_K];
            double max = Double.MIN_VALUE;
            for (int k = 0; k < _K; k++) {
                double eLogTheta_dk = Gamma.digamma(gamma_d[k]) - digamma_gammaSum_d;
                double eLogBeta_kw = Gamma.digamma(lambda_label[k]) - digamma_lambdaSum[k];
                final double tempK = eLogTheta_dk + eLogBeta_kw;
                if (tempK > max) {
                    max = tempK;
                }
                temp[k] = tempK;
            }
            double logsumexp = MathUtils.logsumexp(temp, max);

            // sum( word count * logsumexp(...) )
            score += e.getValue().floatValue() * logsumexp;
        }

        // E[log p(theta | alpha) - log q(theta | gamma)]
        for (int k = 0; k < _K; k++) {
            float gamma_dk = gamma_d[k];

            // sum( (alpha - gammad) * Elogthetad )
            score += (_alpha - gamma_dk) * (Gamma.digamma(gamma_dk) - digamma_gammaSum_d);

            // sum( gammaln(gammad) - gammaln(alpha) )
            score += Gamma.logGamma(gamma_dk) - logGamma_alpha;
        }
        score += logGamma_alphaSum; // gammaln(sum(alpha))
        score -= Gamma.logGamma(gammaSum[d]); // gammaln(sum(gammad))
    }

    // assuming likelihood for when corpus in the documents is only a subset of the whole corpus
    // (i.e., online setting); likelihood should be always roughly on the same scale
    score *= _docRatio;

    final double logGamma_eta = Gamma.logGamma(_eta);
    final double logGamma_etaSum = Gamma.logGamma(_eta * _lambda.size()); // vocabulary size * eta

    // E[log p(beta | eta) - log q (beta | lambda)]
    for (final float[] lambda_label : _lambda.values()) {
        for (int k = 0; k < _K; k++) {
            float lambda_label_k = lambda_label[k];

            // sum( (eta - lambda) * Elogbeta )
            score += (_eta - lambda_label_k) * (Gamma.digamma(lambda_label_k) - digamma_lambdaSum[k]);

            // sum( gammaln(lambda) - gammaln(eta) )
            score += Gamma.logGamma(lambda_label_k) - logGamma_eta;
        }
    }
    for (int k = 0; k < _K; k++) {
        // sum( gammaln(etaSum) - gammaln( lambdaSum_k )
        score += logGamma_etaSum - Gamma.logGamma(lambdaSum[k]);
    }

    return score;
}

From source file:net.ymate.platform.core.lang.TreeObject.java

public TreeObject(Double d) {
    _object = d != null ? d : Double.MIN_VALUE;
    _type = TYPE_DOUBLE;
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.VisioBubbleExport.java

/**
 * Adds all necessary result nodes to the graph for the list of BuildingBlocks.
 *
 * @throws MasterNotFoundException/*w  ww . j av a  2  s . c  om*/
 */
private void addResultNodes() throws MasterNotFoundException {
    LOGGER.debug("entering addResultNodes...");

    /*
     * If scaling is enabled, additional check is necessary, to estimate the size of the frame, in
     * which all to be drawn entities can be enclosed. The scaling factors for the X and Y axis are
     * then calculated respecting this frame.
     */
    if (portfolioOptions.isScalingEnabled()) {
        double tmp;
        double frameSizeX;
        double frameSizeY;
        double locMaxX = Double.MIN_VALUE;
        double locMaxY = Double.MIN_VALUE;

        for (BuildingBlock block : buildingBlocks) {
            // Determine min and max X
            tmp = bubbleSpace.getXDimension().getValue(block).doubleValue();
            if (tmp > locMaxX && tmp != -1) {
                locMaxX = tmp;
            }
            if (tmp < locMinX && tmp != -1) {
                locMinX = tmp;
            }
            // Determine min and max Y
            tmp = bubbleSpace.getYDimension().getValue(block).doubleValue();
            if (tmp > locMaxY && tmp != -1) {
                locMaxY = tmp;
            }
            if (tmp < locMinY && tmp != -1) {
                locMinY = tmp;
            }
        }
        // Estimate frame size, offsets and scaleFactor
        frameSizeX = locMaxX - locMinX;
        frameSizeY = locMaxY - locMinY;

        // Test whether all objects have the same x or y coordinate
        // If this is the case, scaling is being disabled in the corresponding dimension
        // If this check is not made, an infinity scale factor can occur
        if (frameSizeX == 0) {
            frameSizeX = 1;
        }
        if (frameSizeY == 0) {
            frameSizeY = 1;
        }

        scaleFactorX = (MAXIMUM_X - MINIMUM_X) / (frameSizeX * (MAXIMUM_X - MINIMUM_X));
        scaleFactorY = (MAXIMUM_Y - MINIMUM_Y) / (frameSizeY * (MAXIMUM_Y - MINIMUM_Y));

        offsetX = MINIMUM_X;
        offsetY = MINIMUM_Y;
    }

    // the oneDimensionNotSet is relevant only for testing purposes
    if (isOneDimensionNumber() || oneDimensionNotSet()) {
        for (BuildingBlock buildingBlock : buildingBlocks) {
            createBubbleShape(buildingBlock);
        }
    } else {
        createBubbles();
    }
    // Call the shape creation method for each shape

    LOGGER.debug("leaving addResultNodes...");
}

From source file:edu.rice.cs.bioinfo.programs.phylonet.algos.network.NetworkPseudoLikelihoodFromGTT.java

protected double findOptimalBranchLength(final Network<Object> speciesNetwork,
        final Map<String, List<String>> species2alleles, final List tripleFrequencies,
        final List gtCorrespondence, final Set<String> singleAlleleSpecies) {
    boolean continueRounds = true; // keep trying to improve network

    for (NetNode<Object> node : speciesNetwork.dfs()) {
        for (NetNode<Object> parent : node.getParents()) {
            node.setParentDistance(parent, 1.0);
            if (node.isNetworkNode()) {
                node.setParentProbability(parent, 0.5);
            }/*from  w ww.j  a v a2  s. com*/
        }
    }

    Set<NetNode> node2ignoreForBL = findEdgeHavingNoBL(speciesNetwork);

    double initalProb = computeProbability(speciesNetwork, tripleFrequencies, species2alleles,
            gtCorrespondence);
    if (_printDetails)
        System.out.println(speciesNetwork.toString() + " : " + initalProb);

    final Container<Double> lnGtProbOfSpeciesNetwork = new Container<Double>(initalProb); // records the GTProb of the network at all times

    int roundIndex = 0;
    for (; roundIndex < _maxRounds && continueRounds; roundIndex++) {
        /*
        * Prepare a random ordering of network edge examinations each of which attempts to change a branch length or hybrid prob to improve the GTProb score.
        */
        double lnGtProbLastRound = lnGtProbOfSpeciesNetwork.getContents();
        List<Proc> assigmentActions = new ArrayList<Proc>(); // store adjustment commands here.  Will execute them one by one later.

        for (final NetNode<Object> parent : edu.rice.cs.bioinfo.programs.phylonet.structs.network.util.Networks
                .postTraversal(speciesNetwork)) {

            for (final NetNode<Object> child : parent.getChildren()) {
                if (node2ignoreForBL.contains(child)) {
                    continue;
                }

                assigmentActions.add(new Proc() {
                    public void execute() {

                        UnivariateFunction functionToOptimize = new UnivariateFunction() {
                            public double value(double suggestedBranchLength) {
                                double incumbentBranchLength = child.getParentDistance(parent);

                                child.setParentDistance(parent, suggestedBranchLength);

                                double lnProb = computeProbability(speciesNetwork, tripleFrequencies,
                                        species2alleles, gtCorrespondence);
                                //System.out.println(speciesNetwork + ": " + lnProb);
                                if (lnProb > lnGtProbOfSpeciesNetwork.getContents()) // did improve, keep change
                                {
                                    lnGtProbOfSpeciesNetwork.setContents(lnProb);

                                } else // didn't improve, roll back change
                                {
                                    child.setParentDistance(parent, incumbentBranchLength);
                                }
                                return lnProb;
                            }
                        };
                        BrentOptimizer optimizer = new BrentOptimizer(_Brent1, _Brent2); // very small numbers so we control when brent stops, not brent.

                        try {
                            optimizer.optimize(_maxTryPerBranch, functionToOptimize, GoalType.MAXIMIZE,
                                    Double.MIN_VALUE, _maxBranchLength);
                        } catch (TooManyEvaluationsException e) // _maxAssigmentAttemptsPerBranchParam exceeded
                        {
                        }

                        if (_printDetails)
                            System.out.println(
                                    speciesNetwork.toString() + " : " + lnGtProbOfSpeciesNetwork.getContents());

                    }
                });
            }
        }

        for (final NetNode<Object> child : speciesNetwork.getNetworkNodes()) // find every hybrid node
        {

            Iterator<NetNode<Object>> hybridParents = child.getParents().iterator();
            final NetNode hybridParent1 = hybridParents.next();
            final NetNode hybridParent2 = hybridParents.next();

            assigmentActions.add(new Proc() {
                public void execute() {
                    UnivariateFunction functionToOptimize = new UnivariateFunction() {
                        public double value(double suggestedProb) {
                            double incumbentHybridProbParent1 = child.getParentProbability(hybridParent1);

                            child.setParentProbability(hybridParent1, suggestedProb);
                            child.setParentProbability(hybridParent2, 1.0 - suggestedProb);

                            double lnProb = computeProbability(speciesNetwork, tripleFrequencies,
                                    species2alleles, gtCorrespondence);
                            //System.out.println(speciesNetwork + ": " + lnProb);
                            if (lnProb > lnGtProbOfSpeciesNetwork.getContents()) // change improved GTProb, keep it
                            {

                                lnGtProbOfSpeciesNetwork.setContents(lnProb);
                            } else // change did not improve, roll back
                            {

                                child.setParentProbability(hybridParent1, incumbentHybridProbParent1);
                                child.setParentProbability(hybridParent2, 1.0 - incumbentHybridProbParent1);
                            }
                            return lnProb;
                        }
                    };
                    BrentOptimizer optimizer = new BrentOptimizer(_Brent1, _Brent2); // very small numbers so we control when brent stops, not brent.

                    try {
                        optimizer.optimize(_maxTryPerBranch, functionToOptimize, GoalType.MAXIMIZE, 0, 1.0);
                    } catch (TooManyEvaluationsException e) // _maxAssigmentAttemptsPerBranchParam exceeded
                    {
                    }
                    if (_printDetails)
                        System.out.println(
                                speciesNetwork.toString() + " : " + lnGtProbOfSpeciesNetwork.getContents());
                }
            });

        }

        // add hybrid probs to hybrid edges
        Collections.shuffle(assigmentActions);

        for (Proc assigment : assigmentActions) // for each change attempt, perform attempt
        {
            assigment.execute();
        }
        if (_printDetails) {
            System.out.println("Round end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            System.out
                    .println(speciesNetwork.toString() + "\n" + lnGtProbOfSpeciesNetwork.getContents() + "\n");
        }
        if (((double) lnGtProbOfSpeciesNetwork.getContents()) == lnGtProbLastRound) // if no improvement was made wrt to last around, stop trying to find a better assignment
        {
            continueRounds = false;
        } else if (lnGtProbOfSpeciesNetwork.getContents() > lnGtProbLastRound) // improvement was made, ensure it is large enough wrt to improvement threshold to continue searching
        {

            double improvementPercentage = Math.pow(Math.E,
                    (lnGtProbOfSpeciesNetwork.getContents() - lnGtProbLastRound)) - 1.0; // how much did we improve over last round
            if (improvementPercentage < _improvementThreshold) // improved, but not enough to keep searching
            {
                continueRounds = false;
            }
        } else {
            throw new IllegalStateException("Should never have decreased prob.");
        }
    }
    //System.out.println(speciesNetwork + " " + lnGtProbOfSpeciesNetwork.getContents());
    return lnGtProbOfSpeciesNetwork.getContents();
}

From source file:gov.nih.nci.cma.web.graphing.CMAPrincipalComponentAnalysisPlot.java

/**
 * Get the range of values for a given clinical factor
 * @param dataPoints/*from w w w.  j  ava  2s.c  om*/
 * @param factor
 * @return
 */
private DataRange getDataRange(Collection<CMAPCADataPoint> dataPoints, PCAcomponent component) {
    double maxValue = Double.MIN_VALUE;
    double minValue = Double.MAX_VALUE;
    double value;

    for (CMAPCADataPoint dataPoint : dataPoints) {
        value = dataPoint.getComponentValue(component);
        if (value < minValue) {
            minValue = value;
        }

        if (value > maxValue) {
            maxValue = value;
        }
    }

    DataRange range = new DataRange(minValue, maxValue);
    return range;
}

From source file:com.vgi.mafscaling.ClosedLoop.java

protected void createGraghTab() {
    JPanel cntlPanel = new JPanel();
    JPanel plotPanel = createGraphPlotPanel(cntlPanel);
    add(plotPanel, "<html><div style='text-align: center;'>C<br>h<br>a<br>r<br>t</div></html>");

    GridBagLayout gbl_cntlPanel = new GridBagLayout();
    gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_cntlPanel.rowHeights = new int[] { 0, 0 };
    gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_cntlPanel.rowWeights = new double[] { 0 };
    cntlPanel.setLayout(gbl_cntlPanel);/*from w ww. j  a v  a  2s.co  m*/

    GridBagConstraints gbc_check = new GridBagConstraints();
    gbc_check.insets = insets2;
    gbc_check.gridx = 0;
    gbc_check.gridy = 0;

    checkBoxDvdtData = new JCheckBox("dV/dt");
    checkBoxDvdtData.setActionCommand("dvdt");
    checkBoxDvdtData.addActionListener(this);
    cntlPanel.add(checkBoxDvdtData, gbc_check);

    gbc_check.gridx++;
    checkBoxIatData = new JCheckBox("IAT");
    checkBoxIatData.setActionCommand("iat");
    checkBoxIatData.addActionListener(this);
    cntlPanel.add(checkBoxIatData, gbc_check);

    gbc_check.gridx++;
    checkBoxTrpmData = new JCheckBox("Trims/RPM");
    checkBoxTrpmData.setActionCommand("trpm");
    checkBoxTrpmData.addActionListener(this);
    cntlPanel.add(checkBoxTrpmData, gbc_check);

    gbc_check.gridx++;
    checkBoxMnmdData = new JCheckBox("Mean/Mode");
    checkBoxMnmdData.setActionCommand("mnmd");
    checkBoxMnmdData.addActionListener(this);
    cntlPanel.add(checkBoxMnmdData, gbc_check);

    gbc_check.gridx++;
    checkBoxRunData = new JCheckBox("Total Correction");
    checkBoxRunData.setActionCommand("corrdata");
    checkBoxRunData.addActionListener(this);
    cntlPanel.add(checkBoxRunData, gbc_check);

    gbc_check.gridx++;
    createGraphCommonControls(cntlPanel, gbc_check.gridx);

    createChart(plotPanel, Y2AxisName);
    createMafSmoothingPanel(plotPanel);
}

From source file:afest.datastructures.tree.decision.erts.grower.AERTGrower.java

/**
 * Create a split on the given attribute by choosing a uniformly random threshold in [min, max).
 * @param <T> Type of ITrainingPoints used by the Extra Trees.
 * @param set set containing the points in which we choose the threshold.
 * @param attribute attribute to pick the threshold for.
 * @return a split on the given attribute by choosing a uniformly random threshold in [min, max).
 *///  w  w w  .  j  av a 2s  . com
private <T extends ITrainingPoint<R, O>> ERTSplit<R> createSplit(Collection<T> set, R attribute) {
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    for (T aT : set) {
        double value = aT.getValue(attribute);
        if (value > max) {
            max = value;
        }
        if (value < min) {
            min = value;
        }
    }

    if (Double.isInfinite(max)) {
        max = Double.MAX_VALUE;
    }
    if (Double.isInfinite(min)) {
        min = -Double.MAX_VALUE;
    }

    max = max - Double.MIN_VALUE;
    min = min + Double.MIN_VALUE;
    double threshold = fRandom.nextDouble() * (max - min) + min;
    ERTSplit<R> split = new ERTSplit<R>(attribute, threshold);
    return split;
}

From source file:playground.johannes.snowball2.SnowballExe.java

private double calcGammaExponent(Histogram hist) {
    double minVal = hist.getBinLowerBound(hist.getMaxBin());
    if (minVal == 0)
        minVal = Double.MIN_VALUE;
    double wsum = 0;
    double logsum = 0;
    for (int i = 0; i < hist.getValues().size(); i++) {
        if (hist.getValues().get(i) >= minVal) {
            double w = hist.getWeights().get(i);
            logsum += Math.log(hist.getValues().get(i) / minVal) * w;
            wsum += w;//from   w  ww .j  a v  a 2s  . co  m
        }
    }

    return 1 + (wsum / logsum);
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIHelper.java

/***********************************************************************************************
 * Update the Domain Slider Crosshair.// w w  w  . jav a2  s.  c  om
 *
 * @param chartui
 * @param movingindex
 * @param domainstart
 * @param domainend
 * @param movingslidervalue
 * @param sliderminimum
 * @param slidermaximum     *
 * @param debug
 *
 * @return double
 */

public static double updateDomainCrosshairForDomainSlider(final ChartUIComponentPlugin chartui,
        final int movingindex, final int domainstart, final int domainend, final int movingslidervalue,
        final int sliderminimum, final int slidermaximum, final boolean debug) {
    final String SOURCE = "ChartHelper.updateDomainCrosshairForDomainSlider() ";
    final double dblDomainCrosshairXYPlot;

    if ((chartui.getChartPanel() != null) && (chartui.getChartPanel().getChart() != null)
            && (chartui.getChartPanel().getChart().getPlot() != null)) {
        final double dblDomainCrosshair;
        final double dblPositionFraction;
        final XYPlot plot;
        final ValueAxis domainAxis;
        final Range range;

        plot = (XYPlot) chartui.getChartPanel().getChart().getPlot();
        domainAxis = plot.getDomainAxis();
        range = domainAxis.getRange();

        if (movingindex == INDEX_LEFT) {
            // Trying to Move Left, but are we already at the Left Extent?
            if (movingslidervalue <= sliderminimum) {
                dblDomainCrosshair = sliderminimum;

                dblDomainCrosshairXYPlot = domainAxis.getLowerBound();

                FrameworkSingletons.LOGGER.debug(debug,
                        SOURCE + "At Left Extent, cannot move Left Thumb to the Left" + "  [crosshair.domain="
                                + dblDomainCrosshair + "] [crosshair.xyplot" + dblDomainCrosshairXYPlot + "]");
            }
            // It is Ok to move further Left than the current setting of domainstart,
            // but we musn't draw a crosshair
            else if (movingslidervalue < domainstart) {
                // Do not draw a crosshair, set to lower bound?
                dblDomainCrosshair = sliderminimum;

                dblDomainCrosshairXYPlot = domainAxis.getLowerBound();

                FrameworkSingletons.LOGGER.debug(debug,
                        SOURCE + "Moving Left Thumb to the Left beyond current DomainStart"
                                + "  [crosshair.domain=" + dblDomainCrosshair + "] [crosshair.xyplot"
                                + dblDomainCrosshairXYPlot + "]");
            } else {
                // Try to Move Right, the slider won't be able to move past the Right Thumb
                dblDomainCrosshair = movingslidervalue;

                dblPositionFraction = (double) (movingslidervalue - domainstart)
                        / (double) (domainend - domainstart);
                dblDomainCrosshairXYPlot = domainAxis.getLowerBound()
                        + (dblPositionFraction * range.getLength());

                FrameworkSingletons.LOGGER.debug(debug,
                        SOURCE + "Moving Left Thumb to the Right" + "  [crosshair.domain=" + dblDomainCrosshair
                                + "] [crosshair.xyplot" + dblDomainCrosshairXYPlot + "]");
            }
        } else if (movingindex == INDEX_RIGHT) {
            //  Trying to Move Right, but are we already at the Right Extent?
            if (movingslidervalue >= slidermaximum) {
                dblDomainCrosshair = slidermaximum;

                dblDomainCrosshairXYPlot = domainAxis.getLowerBound() + range.getLength();

                FrameworkSingletons.LOGGER.debug(debug,
                        SOURCE + "At Right Extent, cannot move Right Thumb to the Right"
                                + "  [crosshair.domain=" + dblDomainCrosshair + "] [crosshair.xyplot"
                                + dblDomainCrosshairXYPlot + "]");
            }
            // It is Ok to move further Right than the current setting of domainend
            // but we musn't draw a crosshair
            else if (movingslidervalue > domainend) {
                // Do not draw a crosshair, set to upper bound?
                dblDomainCrosshair = slidermaximum;

                dblDomainCrosshairXYPlot = domainAxis.getLowerBound() + range.getLength();

                FrameworkSingletons.LOGGER.debug(debug,
                        SOURCE + "Moving Right Thumb to the Right beyond current DomainEnd"
                                + "  [crosshair.domain=" + dblDomainCrosshair + "] [crosshair.xyplot"
                                + dblDomainCrosshairXYPlot + "]");
            } else {
                // Try to Move Left, the slider won't be able to move past the Left Thumb
                dblDomainCrosshair = movingslidervalue;

                dblPositionFraction = (double) (movingslidervalue - domainstart)
                        / (double) (domainend - domainstart);
                dblDomainCrosshairXYPlot = domainAxis.getLowerBound()
                        + (dblPositionFraction * range.getLength());

                FrameworkSingletons.LOGGER.debug(debug,
                        SOURCE + "Moving Right Thumb to the Left" + "  [crosshair.domain=" + dblDomainCrosshair
                                + "] [crosshair.xyplot" + dblDomainCrosshairXYPlot + "]");
            }
        } else {
            // Do nothing, an Error
            dblDomainCrosshair = sliderminimum;
            dblDomainCrosshairXYPlot = domainAxis.getLowerBound();

            FrameworkSingletons.LOGGER.debug(debug, SOURCE + "Invalid Thumb index" + "  [crosshair.domain="
                    + dblDomainCrosshair + "] [crosshair.xyplot" + dblDomainCrosshairXYPlot + "]");
        }

        chartui.setDomainCrosshair(dblDomainCrosshair);
        plot.setDomainCrosshairValue(dblDomainCrosshairXYPlot);
    } else {
        chartui.setDomainCrosshair(sliderminimum);
        dblDomainCrosshairXYPlot = Double.MIN_VALUE;

        FrameworkSingletons.LOGGER.debug(debug,
                SOURCE + "There is no Chart, so cannot update Domain Slider Crosshair" + "  [crosshair.domain="
                        + sliderminimum + "] [crosshair.xyplot" + dblDomainCrosshairXYPlot + "]");
    }

    return (dblDomainCrosshairXYPlot);
}