@Override public String getString(int id) { assert id < _idToValueMap.size(); return (Double.valueOf(_idToValueMap.getDouble(id)).toString()); } }
private void assertTDigest(TDigest tDigest, DoubleList doubleList) { for (int percentile = 0; percentile <= 100; percentile++) { double expected; if (percentile == 100) { expected = doubleList.getDouble(doubleList.size() - 1); } else { expected = doubleList.getDouble(doubleList.size() * percentile / 100); } Assert .assertEquals(PercentileTDigestAggregationFunction.calculatePercentile(tDigest, percentile), expected, DELTA, ERROR_MESSAGE); } }
/** * Get the last training RMSE of the feature. * * @return The RMSE of the last iteration training this feature. */ public double getLastRMSE() { return trainingErrors.getDouble(trainingErrors.size() - 1); }
/** * Create a map from an array and index mapping. * * @param mapping The index mapping specifying the keys. * @param values The array of values. * @return A sparse vector mapping the IDs in {@code map} to the values in {@code values}. * @throws IllegalArgumentException if {@code values} not the same size as {@code idx}. */ public static Long2DoubleSortedArrayMap fromArray(KeyIndex mapping, DoubleList values) { Preconditions.checkArgument(values.size() == mapping.size(), "value array and index have different sizes: " + values.size() + " != " + mapping.size()); final int n = values.size(); double[] nvs = new double[n]; SortedKeyIndex index = SortedKeyIndex.fromCollection(mapping.getKeyList()); for (int i = 0; i < n; i++) { long item = index.getKey(i); int origIndex = mapping.getIndex(item); nvs[i] = values.getDouble(origIndex); } return wrap(index, nvs); }
@Override public double getDouble(final int i) { synchronized (sync) { return list.getDouble(i); } } @Override
@Override public double getDouble(final int i) { return list.getDouble(i); } @Override
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Double get(int index) { return Double.valueOf(getDouble(index)); } /**
@Override public double getDouble(long index) { return list.getDouble(intIndex(index)); } @Override
@Override public double previousDouble() { if (!hasPrevious()) throw new NoSuchElementException(); return l.getDouble(from + (last = --pos)); } @Override
@Override public double getDouble(final int index) { ensureRestrictedIndex(index); return l.getDouble(from + index); } @Override
@Override public double nextDouble() { if (!hasNext()) throw new NoSuchElementException(); return l.getDouble(from + (last = pos++)); } @Override
/** * Get the last training RMSE of the feature. * * @return The RMSE of the last iteration training this feature. */ public double getLastRMSE() { return trainingErrors.getDouble(trainingErrors.size() - 1); }
/** * Shuffles the specified list using the specified pseudorandom number * generator. * * @param l * the list to be shuffled. * @param random * a pseudorandom number generator. * @return {@code l}. */ public static DoubleList shuffle(final DoubleList l, final Random random) { for (int i = l.size(); i-- != 0;) { final int p = random.nextInt(i + 1); final double t = l.getDouble(i); l.set(i, l.getDouble(p)); l.set(p, t); } return l; } /**
baseSchedule.objectiveValues.getDouble(i));
static DoubleList replace(DoubleList list, IntList indices, DoubleList elements) { checkIndices(indices, elements); final DoubleList newL = new DoubleArrayList(list); for (int i = 0; i < indices.size(); i++) { newL.set(indices.getInt(i), elements.getDouble(i)); } return DoubleLists.unmodifiable(newL); }
final double originalCost = s.objectiveValues.getDouble(swap.fromRow()); final ImmutableList<T> newRoute = inListSwap(s.routes.get(swap.fromRow()), swap.toIndices(), swap.item()); final double originalCostA = s.objectiveValues.getDouble(swap.fromRow()); final ImmutableList<T> newRouteA = ImmutableList.copyOf(filter( s.routes.get(swap.fromRow()), not(equalTo(swap.item())))); final double originalCostB = s.objectiveValues.getDouble(swap.toRow()); final ImmutableList<T> newRouteB = Insertions.insert( s.routes.get(swap.toRow()), swap.toIndices(), swap.item());