This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch Fixes_for_getPartitionBoundaries
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git

commit a57677487a44e2d65077d0c9717030355c29a495
Author: Lee Rhodes <[email protected]>
AuthorDate: Wed Oct 25 17:31:28 2023 -0700

    This applies the same fix that eliminates duplicate entries when using
    getPartitionBoundaries(...) in all the quantile sketches for small
    values of N.
---
 .../java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java   | 3 +--
 .../java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java    | 3 +--
 .../java/org/apache/datasketches/kll/KllItemsSketchSortedView.java     | 3 +--
 .../org/apache/datasketches/quantiles/DoublesSketchSortedView.java     | 3 +--
 .../org/apache/datasketches/quantilescommon/QuantilesFloatsAPI.java    | 2 +-
 src/main/java/org/apache/datasketches/req/ReqSketchSortedView.java     | 3 +--
 6 files changed, 6 insertions(+), 11 deletions(-)

diff --git 
a/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java 
b/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java
index 03259b95..a5d50297 100644
--- a/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java
@@ -83,8 +83,7 @@ public final class KllDoublesSketchSortedView implements 
DoublesSortedView {
     if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
     QuantilesUtil.checkNormalizedRankBounds(rank);
     final int len = cumWeights.length;
-    final long naturalRank = (searchCrit == INCLUSIVE)
-        ? (long)Math.ceil(rank * totalN) : (long)Math.floor(rank * totalN);
+    final long naturalRank = Math.round(rank * totalN);
     final InequalitySearch crit = (searchCrit == INCLUSIVE) ? 
InequalitySearch.GE : InequalitySearch.GT;
     final int index = InequalitySearch.find(cumWeights, 0, len - 1, 
naturalRank, crit);
     if (index == -1) {
diff --git 
a/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java 
b/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java
index 6a378531..41dfb099 100644
--- a/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java
@@ -83,8 +83,7 @@ public final class KllFloatsSketchSortedView implements 
FloatsSortedView {
     if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
     QuantilesUtil.checkNormalizedRankBounds(rank);
     final int len = cumWeights.length;
-    final long naturalRank = (searchCrit == INCLUSIVE)
-        ? (long)Math.ceil(rank * totalN) : (long)Math.floor(rank * totalN);
+    final long naturalRank = Math.round(rank * totalN);
     final InequalitySearch crit = (searchCrit == INCLUSIVE) ? 
InequalitySearch.GE : InequalitySearch.GT;
     final int index = InequalitySearch.find(cumWeights, 0, len - 1, 
naturalRank, crit);
     if (index == -1) {
diff --git 
a/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java 
b/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
index c3fb8bab..40d8117d 100644
--- a/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
@@ -133,8 +133,7 @@ public class KllItemsSketchSortedView<T> implements 
GenericSortedView<T> {
     if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
     QuantilesUtil.checkNormalizedRankBounds(rank);
     final int len = cumWeights.length;
-    final long naturalRank = (searchCrit == INCLUSIVE)
-        ? (long)Math.ceil(rank * totalN) : (long)Math.floor(rank * totalN);
+    final long naturalRank = Math.round(rank * totalN);
     final InequalitySearch crit = (searchCrit == INCLUSIVE) ? 
InequalitySearch.GE : InequalitySearch.GT;
     final int index = InequalitySearch.find(cumWeights, 0, len - 1, 
naturalRank, crit);
     if (index == -1) {
diff --git 
a/src/main/java/org/apache/datasketches/quantiles/DoublesSketchSortedView.java 
b/src/main/java/org/apache/datasketches/quantiles/DoublesSketchSortedView.java
index 02ccdd03..ec359df1 100644
--- 
a/src/main/java/org/apache/datasketches/quantiles/DoublesSketchSortedView.java
+++ 
b/src/main/java/org/apache/datasketches/quantiles/DoublesSketchSortedView.java
@@ -83,8 +83,7 @@ public final class DoublesSketchSortedView implements 
DoublesSortedView {
     if (isEmpty()) { throw new 
IllegalArgumentException(QuantilesAPI.EMPTY_MSG); }
     QuantilesUtil.checkNormalizedRankBounds(rank);
     final int len = cumWeights.length;
-    final long naturalRank = (searchCrit == INCLUSIVE)
-        ? (long)Math.ceil(rank * totalN) : (long)Math.floor(rank * totalN);
+    final long naturalRank = Math.round(rank * totalN);
     final InequalitySearch crit = (searchCrit == INCLUSIVE) ? 
InequalitySearch.GE : InequalitySearch.GT;
     final int index = InequalitySearch.find(cumWeights, 0, len - 1, 
naturalRank, crit);
     if (index == -1) {
diff --git 
a/src/main/java/org/apache/datasketches/quantilescommon/QuantilesFloatsAPI.java 
b/src/main/java/org/apache/datasketches/quantilescommon/QuantilesFloatsAPI.java
index aebdc46b..c6ea484c 100644
--- 
a/src/main/java/org/apache/datasketches/quantilescommon/QuantilesFloatsAPI.java
+++ 
b/src/main/java/org/apache/datasketches/quantilescommon/QuantilesFloatsAPI.java
@@ -237,7 +237,7 @@ public interface QuantilesFloatsAPI extends QuantilesAPI {
    * Gets the upper bound of the quantile confidence interval in which the 
true quantile of the
    * given rank exists.
    *
-   * <p>Although it is possible to estimate the probablity that the true 
quantile
+   * <p>Although it is possible to estimate the probability that the true 
quantile
    * exists within the quantile confidence interval specified by the upper and 
lower quantile bounds,
    * it is not possible to guarantee the width of the quantile interval
    * as an additive or multiplicative percent of the true quantile.</p>
diff --git a/src/main/java/org/apache/datasketches/req/ReqSketchSortedView.java 
b/src/main/java/org/apache/datasketches/req/ReqSketchSortedView.java
index 1b8586ab..cb8bc4a5 100644
--- a/src/main/java/org/apache/datasketches/req/ReqSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/req/ReqSketchSortedView.java
@@ -70,8 +70,7 @@ public final class ReqSketchSortedView implements 
FloatsSortedView {
     if (isEmpty()) { throw new 
IllegalArgumentException(QuantilesAPI.EMPTY_MSG); }
     QuantilesUtil.checkNormalizedRankBounds(rank);
     final int len = cumWeights.length;
-    final long naturalRank = (searchCrit == INCLUSIVE)
-        ? (long)Math.ceil(rank * totalN) : (long)Math.floor(rank * totalN);
+    final long naturalRank = Math.round(rank * totalN);
     final InequalitySearch crit = (searchCrit == INCLUSIVE) ? 
InequalitySearch.GE : InequalitySearch.GT;
     final int index = InequalitySearch.find(cumWeights, 0, len - 1, 
naturalRank, crit);
     if (index == -1) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to