it.unimi.dsi.fastutil.doubles.DoubleSet Java Examples
The following examples show how to use
it.unimi.dsi.fastutil.doubles.DoubleSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DioriteRandomUtils.java From Diorite with MIT License | 6 votes |
@Nullable public static <T> T getWeightedRandomReversed(Random random, Double2ObjectMap<T> choices) { double i = 0; DoubleSet doubles = choices.keySet(); for (DoubleIterator iterator = doubles.iterator(); iterator.hasNext(); ) { double x = iterator.nextDouble(); i += x; } i = getRandomDouble(random, 0, i); for (Double2ObjectMap.Entry<T> entry : choices.double2ObjectEntrySet()) { i -= entry.getDoubleKey(); if (i < 0) { return entry.getValue(); } } return null; }
Example #2
Source File: UniformDistributionThresholdProviderThresholdFilter.java From metanome-algorithms with Apache License 2.0 | 6 votes |
@Override public Iterable<Double> filter(DoubleSet similarities) { if (similarities.isEmpty()) { return DoubleSets.EMPTY_SET; } DoubleSortedSet filtered = sorted(similarities); double first = filtered.firstDouble(); int intervals = size - 1; if (intervals == 0) { return DoubleSets.singleton(first); } double last = filtered.lastDouble(); double intervalSize = (first - last) / intervals; UniformTrimmer trimmer = new UniformTrimmer(intervalSize); OfDouble iterator = filtered.iterator(); trimmer.trim(iterator); return filtered; }
Example #3
Source File: ValueInTransformFunction.java From incubator-pinot with Apache License 2.0 | 5 votes |
private static double[] filterDoubles(DoubleSet doubleSet, double[] source) { DoubleList doubleList = new DoubleArrayList(); for (double value : source) { if (doubleSet.contains(value)) { doubleList.add(value); } } if (doubleList.size() == source.length) { return source; } else { return doubleList.toDoubleArray(); } }
Example #4
Source File: DoubleColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { DoubleSet uniqueElements = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { uniqueElements.add(getDouble(i)); } return uniqueElements.size(); }
Example #5
Source File: DoubleColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public DoubleColumn unique() { final DoubleSet doubles = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { doubles.add(getDouble(i)); } final DoubleColumn column = DoubleColumn.create(name() + " Unique values"); doubles.forEach((DoubleConsumer) column::append); return column; }
Example #6
Source File: Int2Int2DoubleArrayTable.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@Override public DoubleSet values() { DoubleSet result = new DoubleOpenHashSet(); Arrays.stream(array) .filter(Objects::nonNull) .map(Int2DoubleRow::values) .flatMap(DoubleCollection::stream) .mapToDouble(Double::doubleValue) .forEach(result::add); return result; }
Example #7
Source File: DoubleColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { DoubleSet uniqueElements = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { uniqueElements.add(getDouble(i)); } return uniqueElements.size(); }
Example #8
Source File: DoubleColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public DoubleColumn unique() { final DoubleSet doubles = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { doubles.add(getDouble(i)); } final DoubleColumn column = DoubleColumn.create(name() + " Unique values"); doubles.forEach((DoubleConsumer) column::append); return column; }
Example #9
Source File: UniformTrimmerTest.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@Test public void testExact() { ThresholdFilter thresholdFilter = new UniformDistributionThresholdProviderThresholdFilter(3, new ExactThresholdFilter()); DoubleSet similarities = new DoubleOpenHashSet(new double[]{0.2, 0.3, 0.4, 0.5, 0.6}); Iterable<Double> thresholds = thresholdFilter.filter(similarities); assertThat(thresholds).hasSize(3); assertThat(thresholds).contains(Double.valueOf(0.2), Double.valueOf(0.4), Double.valueOf(0.6)); }
Example #10
Source File: UniformTrimmerTest.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@Test public void test() { ThresholdFilter thresholdFilter = new UniformDistributionThresholdProviderThresholdFilter(3, new ExactThresholdFilter()); DoubleSet similarities = new DoubleOpenHashSet(new double[]{0.2, 0.3, 0.4, 0.5}); Iterable<Double> thresholds = thresholdFilter.filter(similarities); assertThat(thresholds).hasSize(3); assertThat(thresholds).contains(Double.valueOf(0.2), Double.valueOf(0.3), Double.valueOf(0.5)); }
Example #11
Source File: MultiThresholdProviderTest.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@Test public void testGetNext() { List<DoubleSet> similarities = Arrays .asList(new DoubleOpenHashSet(Sets.newHashSet(Double.valueOf(0.7), Double.valueOf(0.6))), new DoubleOpenHashSet(Sets.newHashSet(Double.valueOf(0.8)))); ThresholdProvider provider = create(similarities); assertThat(provider.getNext(0, 0.5).boxed()).hasValue(Double.valueOf(0.6)); assertThat(provider.getNext(0, 0.6).boxed()).hasValue(Double.valueOf(0.7)); assertThat(provider.getNext(1, 0.8).boxed()).isEmpty(); }
Example #12
Source File: ExactThresholdFilter.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public DoubleSet filter(DoubleSet similarities) { return similarities; }
Example #13
Source File: MultiThresholdProviderTest.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Test public void testEmpty() { List<DoubleSet> similarities = Collections.singletonList(new DoubleOpenHashSet()); ThresholdProvider provider = create(similarities); assertThat(provider.getNext(0, 0.0).boxed()).isEmpty(); }
Example #14
Source File: MultiThresholdProviderTest.java From metanome-algorithms with Apache License 2.0 | 4 votes |
private static ThresholdProvider create(Iterable<DoubleSet> similarities) { return MultiThresholdProvider.create(similarities); }
Example #15
Source File: LimitSizeThresholdFilter.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public Iterable<Double> filter(DoubleSet similarities) { return LimitSizeUtils.limitSize(similarities, size); }
Example #16
Source File: LimitSizeUtils.java From metanome-algorithms with Apache License 2.0 | 4 votes |
public static Iterable<Double> limitSize(DoubleCollection similarities, int size) { DoubleSet filtered = ThresholdFilterUtils.sorted(similarities); Trimmer trimmer = new Trimmer(size); trimmer.trim(filtered); return filtered; }
Example #17
Source File: StepThresholdFilter.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public Iterable<Double> filter(DoubleSet similarities) { return steps; }
Example #18
Source File: PreprocessedColumnPairImpl.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public Iterable<Double> getThresholds(ThresholdFilter thresholdFilter) { DoubleSet similarities = similarityIndex.getSimilarities(); return thresholdFilter.filter(similarities); }
Example #19
Source File: ThresholdSimilarityIndex.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public DoubleSet getSimilarities() { return similarityTable.values(); }
Example #20
Source File: SlimSimilarityIndex.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public DoubleSet getSimilarities() { Collection<Double> values = similarityTable.values(); return new DoubleOpenHashSet(values); }
Example #21
Source File: SimilarityIndex.java From metanome-algorithms with Apache License 2.0 | votes |
DoubleSet getSimilarities();
Example #22
Source File: ThresholdFilter.java From metanome-algorithms with Apache License 2.0 | votes |
Iterable<Double> filter(DoubleSet similarities);
Example #23
Source File: Int2Int2DoubleTable.java From metanome-algorithms with Apache License 2.0 | votes |
DoubleSet values();