/** {@inheritDoc} */ @Override public String toString() { return "[" + getKey() + ", " + getValue() + "]"; }
/** * Create an entry representing the same mapping as the specified entry. * * @param entry Entry to copy. */ public Pair(Pair<? extends K, ? extends V> entry) { this(entry.getKey(), entry.getValue()); }
/** * {@inheritDoc} * * @return {@code sum((singletons[i] - mean) ^ 2 * probabilities[i])} */ public double getNumericalVariance() { double mean = 0; double meanOfSquares = 0; for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { mean += sample.getValue() * sample.getKey(); meanOfSquares += sample.getValue() * sample.getKey() * sample.getKey(); } return meanOfSquares - mean * mean; }
/** * {@inheritDoc} * * @return {@code sum((singletons[i] - mean) ^ 2 * probabilities[i])} */ public double getNumericalVariance() { double mean = 0; double meanOfSquares = 0; for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) { mean += sample.getValue() * sample.getKey(); meanOfSquares += sample.getValue() * sample.getKey() * sample.getKey(); } return meanOfSquares - mean * mean; }
/** * {@inheritDoc} * * Returns the highest value with non-zero probability. * * @return the highest value with non-zero probability. */ public int getSupportUpperBound() { int max = Integer.MIN_VALUE; for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() > max && sample.getValue() > 0) { max = sample.getKey(); } } return max; }
/** * {@inheritDoc} * * Returns the lowest value with non-zero probability. * * @return the lowest value with non-zero probability. */ public double getSupportLowerBound() { double min = Double.POSITIVE_INFINITY; for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() < min && sample.getValue() > 0) { min = sample.getKey(); } } return min; }
/** * {@inheritDoc} * * Returns the highest value with non-zero probability. * * @return the highest value with non-zero probability. */ public double getSupportUpperBound() { double max = Double.NEGATIVE_INFINITY; for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() > max && sample.getValue() > 0) { max = sample.getKey(); } } return max; }
/** * {@inheritDoc} * * Returns the lowest value with non-zero probability. * * @return the lowest value with non-zero probability. */ public int getSupportLowerBound() { int min = Integer.MAX_VALUE; for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() < min && sample.getValue() > 0) { min = sample.getKey(); } } return min; }
/** * {@inheritDoc} */ public double cumulativeProbability(final double x) { double probability = 0; for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() <= x) { probability += sample.getValue(); } } return probability; }
/** * {@inheritDoc} * * @return {@code sum(singletons[i] * probabilities[i])} */ public double getNumericalMean() { double mean = 0; for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { mean += sample.getValue() * sample.getKey(); } return mean; }
/** * {@inheritDoc} * * @return {@code sum(singletons[i] * probabilities[i])} */ public double getNumericalMean() { double mean = 0; for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) { mean += sample.getValue() * sample.getKey(); } return mean; }
/** * {@inheritDoc} */ public double cumulativeProbability(final int x) { double probability = 0; for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() <= x) { probability += sample.getValue(); } } return probability; }
singletons.add(sample.getKey()); final double p = sample.getValue(); if (p < 0) {
/** * {@inheritDoc} */ @Override public double inverseCumulativeProbability(final double p) throws OutOfRangeException { if (p < 0.0 || p > 1.0) { throw new OutOfRangeException(p, 0, 1); } double probability = 0; double x = getSupportLowerBound(); for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { if (sample.getValue() == 0.0) { continue; } probability += sample.getValue(); x = sample.getKey(); if (probability >= p) { break; } } return x; }
private boolean checkExecutionErrors(final FileSystem fs, final Path newExecutionOutput) throws IOException { Map<String, List<Pair<EtlKey, ExceptionWritable>>> errors = readErrors(fs, newExecutionOutput); // Print any potential errors encountered if (!errors.isEmpty()) log.error("Errors encountered during job run:"); for (final Entry<String, List<Pair<EtlKey, ExceptionWritable>>> fileEntry : errors.entrySet()) { final String filePath = fileEntry.getKey(); final List<Pair<EtlKey, ExceptionWritable>> errorsFromFile = fileEntry.getValue(); if (errorsFromFile.size() > 0) { log.error("Errors from file [" + filePath + "]"); } for (final Pair<EtlKey, ExceptionWritable> errorEntry : errorsFromFile) { final EtlKey errorKey = errorEntry.getKey(); final ExceptionWritable errorValue = errorEntry.getValue(); log.error("Error for EtlKey [" + errorKey + "]: " + errorValue.toString()); } } return !errors.isEmpty(); }
@Override public void predict(final DataSequence sequence) throws Exception { if (model == null || model.isEmpty()) { throw new IllegalStateException("Model was empty. 'train()' may " + "not have been called."); } // TODO - proper... setting... uggg!! int x = 0; for (int i = 0; i < sequence.size(); i++) { while (x < model.size() && sequence.get(i).time > model.get(x).getKey()) { ++x; } if (x >= model.size()) { break; } if (sequence.get(i).time == model.get(x).getKey()) { final Pair<Long, Double> dp = model.get(x++); sequence.set(i, new Entry(dp.getKey(), (float) (double) dp.getValue())); } } }
/** {@inheritDoc} */ @Override public String toString() { return "[" + getKey() + ", " + getValue() + "]"; }
/** * Create an entry representing the same mapping as the specified entry. * * @param entry Entry to copy. */ public Pair(Pair<? extends K, ? extends V> entry) { this(entry.getKey(), entry.getValue()); }