Example usage for java.lang Double NEGATIVE_INFINITY

List of usage examples for java.lang Double NEGATIVE_INFINITY

Introduction

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

Prototype

double NEGATIVE_INFINITY

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

Click Source Link

Document

A constant holding the negative infinity of type double .

Usage

From source file:bide.hpd.TraceDistribution.java

/**
 * Analyze trace/*from   ww  w  . j  av  a2s .  c  o m*/
 * @param hpdValue TODO
 */
private void analyseDistribution(double[] values, double hpdValue, double burnin) {

    int start = (int) (values.length * burnin);
    values = ArrayUtils.subarray(values, start, values.length);
    //      mean = DiscreteStatistics.mean(values);
    mean = StatUtils.mean(values);
    minimum = Double.POSITIVE_INFINITY;
    maximum = Double.NEGATIVE_INFINITY;

    for (int i = 0; i < values.length; i++) {
        if (values[i] < minimum)
            minimum = values[i];
        if (values[i] > maximum)
            maximum = values[i];
    }

    if (maximum == minimum) {
        isValid = false;
        return;
    }

    int[] indices = new int[values.length];
    HeapSort.sort(values, indices);
    median = statQuantile(0.5, values, indices);
    cpdLower = statQuantile(0.025, values, indices);
    cpdUpper = statQuantile(0.975, values, indices);
    calculateHPDInterval(hpdValue, values, indices);

    isValid = true;
}

From source file:com.inform.jamps.solver.gurobi.GurobiVariable.java

protected GurobiVariable(final GurobiProgram program, final String name, final VariableType type) {
    if (program == null) {
        throw new IllegalArgumentException("Parameter program is mandatory and may not be null");
    }//www  . j  av a 2 s  .c  o m
    if (name == null) {
        throw new IllegalArgumentException("Parameter name is mandatory and may not be null");
    }
    if (type == null) {
        throw new IllegalArgumentException("Parameter type is mandatory and may not be null");
    }

    this.program = program;
    this.name = name;
    this.type = type;

    if (type == VariableType.BINARY) {
        lowerBound = 0.0;
        upperBound = 1.0;
    } else {
        lowerBound = Double.NEGATIVE_INFINITY;
        upperBound = Double.POSITIVE_INFINITY;
    }
}

From source file:ch.algotrader.simulation.SimulationResultFormatter.java

public void formatShort(final Appendable buffer, final SimulationResultVO resultVO) throws IOException {

    PerformanceKeysVO performanceKeys = resultVO.getPerformanceKeys();
    MaxDrawDownVO maxDrawDownVO = resultVO.getMaxDrawDown();

    if (resultVO.getAllTrades().getCount() == 0) {
        buffer.append("no trades took place!");
        return;/*from  w ww. j  a  v a2 s.c  om*/
    }

    Collection<PeriodPerformanceVO> periodPerformanceVOs = resultVO.getMonthlyPerformances();
    double maxDrawDownM = 0d;
    double bestMonthlyPerformance = Double.NEGATIVE_INFINITY;
    if ((periodPerformanceVOs != null)) {
        for (PeriodPerformanceVO PeriodPerformanceVO : periodPerformanceVOs) {
            maxDrawDownM = Math.min(maxDrawDownM, PeriodPerformanceVO.getValue());
            bestMonthlyPerformance = Math.max(bestMonthlyPerformance, PeriodPerformanceVO.getValue());
        }
    }

    buffer.append("avgY=" + twoDigitFormat.format(performanceKeys.getAvgY() * 100.0) + "%");
    buffer.append(" stdY=" + twoDigitFormat.format(performanceKeys.getStdY() * 100) + "%");
    buffer.append(" sharpe=" + twoDigitFormat.format(performanceKeys.getSharpeRatio()));
    buffer.append(" maxDDM=" + twoDigitFormat.format(-maxDrawDownM * 100) + "%");
    buffer.append(" bestMP=" + twoDigitFormat.format(bestMonthlyPerformance * 100) + "%");
    buffer.append(" maxDD=" + twoDigitFormat.format(maxDrawDownVO.getAmount() * 100.0) + "%");
    buffer.append(" maxDDPer=" + twoDigitFormat.format(maxDrawDownVO.getPeriod() / 86400000));
    buffer.append(" winTrds=" + resultVO.getWinningTrades().getCount());
    buffer.append(
            " winTrdsPct="
                    + twoDigitFormat.format(
                            100.0 * resultVO.getWinningTrades().getCount() / resultVO.getAllTrades().getCount())
                    + "%");
    buffer.append(" avgPPctWin=" + twoDigitFormat.format(resultVO.getWinningTrades().getAvgProfitPct() * 100.0)
            + "%");
    buffer.append(" losTrds=" + resultVO.getLoosingTrades().getCount());
    buffer.append(
            " losTrdsPct="
                    + twoDigitFormat.format(
                            100.0 * resultVO.getLoosingTrades().getCount() / resultVO.getAllTrades().getCount())
                    + "%");
    buffer.append(" avgPPctLoos=" + twoDigitFormat.format(resultVO.getLoosingTrades().getAvgProfitPct() * 100.0)
            + "%");
    buffer.append(" totalTrds=" + resultVO.getAllTrades().getCount());

    for (Map.Entry<String, Object> entry : resultVO.getStrategyResults().entrySet()) {
        buffer.append(" " + entry.getKey() + "=" + entry.getValue());
    }

}

From source file:io.sidecar.notification.NotificationRule.java

public NotificationRule(UUID ruleId, String name, String description, UUID appId, UUID userId, String stream,
        String key, double min, double max) {

    this.ruleId = checkNotNull(ruleId);

    checkArgument(StringUtils.isNotBlank(name) && name.length() <= 100);
    this.name = name.trim();

    checkArgument(StringUtils.isBlank(description) || description.length() <= 140);
    this.description = (description == null) ? "" : description.trim();

    this.appId = checkNotNull(appId);

    this.userId = checkNotNull(userId);

    Preconditions.checkArgument(ModelUtils.isValidStreamId(stream));
    this.stream = checkNotNull(stream);

    checkArgument(ModelUtils.isValidReadingKey(key));
    this.key = key;

    this.min = (min == Double.NEGATIVE_INFINITY || min == Double.NaN) ? Double.MIN_VALUE : min;
    this.max = (max == Double.POSITIVE_INFINITY || max == Double.NaN) ? Double.MAX_VALUE : max;
}

From source file:com.davidbracewell.ml.indexing.transform.TfIdfTransform.java

@Override
protected void transformImpl(Instance input) {
    FeatureSet features = input.getFeatures();
    maxTF = Double.NEGATIVE_INFINITY;
    List<DoubleEntry> validEntries = new ArrayList<>();
    for (DoubleEntry entry : CollectionUtils.asIterable(input.nonZeroIterator())) {
        if (shouldTransformFeature(features.get(entry.index).getName())) {
            maxTF = Math.max(maxTF, entry.value);
            validEntries.add(entry);//from  ww  w . j  a v  a  2s. com
        }
    }
    for (DoubleEntry entry : validEntries) {
        Feature feature = features.get(entry.index);
        input.set(entry.index, (0.5 + (0.5 * entry.value) / maxTF) * docFrequency.get(feature));
    }
}

From source file:ml.shifu.shifu.core.binning.MunroPatBinning.java

/**
 * set min/max, merge same bins//from  ww  w  . j  a  v a  2  s  .com
 * In a very skewed data array, this one may not be well performed
 * 
 * @param bins
 *            input bins
 * @return merged bins
 */
private List<Double> binMerge(List<Double> bins) {
    List<Double> newBins = new ArrayList<Double>();
    if (bins.size() == 0) {
        bins.add(Double.NaN);
        return bins;
    }

    Double cur = bins.get(0);
    newBins.add(cur);

    int i = 1;
    while (i < bins.size()) {
        if (Math.abs(cur - bins.get(i)) > 1e-10) {
            newBins.add(bins.get(i));
        }
        cur = bins.get(i);
        i++;
    }

    if (newBins.size() == 1) {
        // special case since there is only 1 candidate in the bins
        double val = newBins.get(0);
        newBins = Arrays.asList(new Double[] { Double.NEGATIVE_INFINITY, val });
    } else if (newBins.size() == 2) {
        newBins.set(0, Double.NEGATIVE_INFINITY);
    } else {
        newBins.set(0, Double.NEGATIVE_INFINITY);
        // remove the max, and became open interval
        newBins.remove(newBins.size() - 1);
    }
    return newBins;
}

From source file:com.clust4j.algo.preprocess.MinMaxScaler.java

@Override
public MinMaxScaler fit(RealMatrix X) {
    synchronized (fitLock) {
        final int m = X.getRowDimension();
        final int n = X.getColumnDimension();

        this.mins = new double[n];
        this.maxes = new double[n];
        double[][] data = X.getData();

        for (int col = 0; col < n; col++) {
            double mn = Double.POSITIVE_INFINITY, mx = Double.NEGATIVE_INFINITY;

            for (int row = 0; row < m; row++) {
                mn = FastMath.min(mn, data[row][col]);
                mx = FastMath.max(mx, data[row][col]);
            }//  w w w  .j  av  a2s .  com

            this.mins[col] = mn;
            this.maxes[col] = mx;
        }

        return this;
    }
}

From source file:beast.math.distributions.InverseGammaDistribution.java

/**
 * the natural log of the probability density function of the distribution
 *
 * @param x     argument/*ww w .j a va  2s.c om*/
 * @param shape shape parameter
 * @param scale scale parameter
 * @return log pdf value
 */
public static double logPdf(double x, double shape, double scale, double factor) {
    if (x <= 0)
        return Double.NEGATIVE_INFINITY;

    return factor - (scale / x) - (shape + 1) * Math.log(x) + shape * Math.log(scale) - Gamma.logGamma(shape);
    //        return  factor + shape*Math.log(scale) - (shape + 1)*Math.log(x) - (scale/x) - GammaFunction.lnGamma(shape);
}

From source file:com.couchbase.sqoop.mapreduce.db.CouchbaseRecordReadSerializeTest.java

@Before
@Override//from  w  w  w . j  ava 2 s  .  com
public void setUp() throws Exception {
    super.setUp();

    tappedStuff = new HashMap<String, ResponseMessage>();

    URI uri = new URI(CouchbaseUtils.CONNECT_STRING);
    String user = CouchbaseUtils.COUCHBASE_USER_NAME;
    String pass = CouchbaseUtils.COUCHBASE_USER_PASS;

    try {
        cb = new CouchbaseClient(Arrays.asList(uri), user, pass);
    } catch (IOException e) {
        LOG.error("Couldn't connect to server" + e.getMessage());
        fail(e.toString());
    }
    this.client = new TapClient(Arrays.asList(uri), user, pass);

    cb.flush();
    Thread.sleep(500);

    // set up the items we're going to deserialize
    Integer anint = new Integer(Integer.MIN_VALUE);
    cb.set(anint.toString(), 0x300, anint).get();

    Long along = new Long(Long.MAX_VALUE);
    cb.set(along.toString(), 0, along).get();

    Float afloat = new Float(Float.MAX_VALUE);
    cb.set(afloat.toString(), 0, afloat).get();

    Double doubleBase = new Double(Double.NEGATIVE_INFINITY);
    cb.set(doubleBase.toString(), 0, doubleBase).get();

    Boolean booleanBase = true;
    cb.set(booleanBase.toString(), 0, booleanBase).get();

    rightnow = new Date(); // instance, needed later
    dateText = rightnow.toString().replaceAll(" ", "_");
    cb.set(dateText, 0, rightnow).get();

    Byte byteMeSix = new Byte("6");
    cb.set(byteMeSix.toString(), 0, byteMeSix).get();

    String ourString = "hi,there";
    cb.set(ourString.toString(), 0, ourString).get();

    client.tapDump("tester");
    while (client.hasMoreMessages()) {
        ResponseMessage m = client.getNextMessage();
        if (m == null) {
            continue;
        }
        tappedStuff.put(m.getKey(), m);
    }
}

From source file:com.cloudera.oryx.rdf.common.information.NumericalInformation.java

static Pair<Decision, Double> bestGain(Iterable<Decision> decisions, ExampleSet examples) {

    UpdatableVariance varianceNegativeStat = new UpdatableVariance();

    // Start with everything considered a negative example:
    for (Example example : examples) {
        float value = ((NumericFeature) example.getTarget()).getValue();
        varianceNegativeStat.increment(value);
    }//  w ww .  java 2s  .  co m

    // Save this off
    double varianceAll = varianceNegativeStat.getResult();
    if (Double.isNaN(varianceAll) || varianceAll <= 0.0) {
        // Weird case, no information at all
        return null;
    }
    // Entropy in nats is ln (stdev * sqrt(2*pi*e)) = ln(stdev) + 0.5*ln(2*pi*e) = 0.5*ln(variance) + ...
    // Actually to compute gain, we only need to know the ln(variance) since the additive constants will
    // fall out when we take the difference in entropies.
    //double entropyAll = 0.5 * Math.log(varianceAll) + HALF_LN_2_PI_E;
    double logVarianceAll = Math.log(varianceAll);

    List<Example> exampleList = examples.getExamples();
    BitSet notYetPositiveExamples = new BitSet(exampleList.size());
    notYetPositiveExamples.set(0, exampleList.size());
    Decision bestDecision = null;
    double bestGain = Double.NEGATIVE_INFINITY;
    UpdatableVariance variancePositiveStat = new UpdatableVariance();

    for (Decision decision : decisions) {
        boolean noChange = true;
        int nextNotYetPositive = -1;
        while ((nextNotYetPositive = notYetPositiveExamples.nextSetBit(nextNotYetPositive + 1)) >= 0) {
            Example example = exampleList.get(nextNotYetPositive);
            if (decision.isPositive(example)) {
                noChange = false;
                float value = ((NumericFeature) example.getTarget()).getValue();
                varianceNegativeStat.decrement(value);
                variancePositiveStat.increment(value);
                notYetPositiveExamples.clear(nextNotYetPositive);
            }
        }
        if (noChange) {
            continue;
        }

        double variancePositive = variancePositiveStat.getResult();
        double varianceNegative = varianceNegativeStat.getResult();
        if (Double.isNaN(variancePositive) || variancePositive <= 0.0 || Double.isNaN(varianceNegative)
                || varianceNegative <= 0.0) {
            continue;
        }

        //double entropyNegative = 0.5 * Math.log(varianceNegative) + HALF_LN_2_PI_E;
        //double entropyPositive = 0.5 * Math.log(variancePositive) + HALF_LN_2_PI_E;
        double logVarianceNegative = Math.log(varianceNegative);
        double logVariancePositive = Math.log(variancePositive);
        long numNegative = varianceNegativeStat.getN();
        long numPositive = variancePositiveStat.getN();
        //double oldgain = entropyAll -
        //    (numNegative * entropyNegative + numPositive * entropyPositive) / (numNegative + numPositive);
        double gain = 0.5
                * (logVarianceAll - (numNegative * logVarianceNegative + numPositive * logVariancePositive)
                        / (numNegative + numPositive));
        if (gain > bestGain) {
            bestGain = gain;
            bestDecision = decision;
        }
    }

    return bestDecision == null ? null : new Pair<Decision, Double>(bestDecision, bestGain);
}