You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2020/04/02 05:59:37 UTC

[incubator-datasketches-java] 02/02: Switched method order

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

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

commit b1bf48af96c5b0f304a539249efcf3d5e95d47bc
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Wed Apr 1 22:59:05 2020 -0700

    Switched method order
---
 .../org/apache/datasketches/hll/HllEstimators.java | 32 +++++++++++-----------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/hll/HllEstimators.java b/src/main/java/org/apache/datasketches/hll/HllEstimators.java
index 0f33746..294624b 100644
--- a/src/main/java/org/apache/datasketches/hll/HllEstimators.java
+++ b/src/main/java/org/apache/datasketches/hll/HllEstimators.java
@@ -45,48 +45,48 @@ class HllEstimators {
    * the very small values <= k where curMin = 0 still apply.
    */
 
-  static final double hllLowerBound(final AbstractHllArray absHllArr, final int numStdDev) {
+  static final double hllUpperBound(final AbstractHllArray absHllArr, final int numStdDev) {
     final int lgConfigK = absHllArr.lgConfigK;
     final int configK = 1 << lgConfigK;
-    final double numNonZeros =
-        (absHllArr.getCurMin() == 0) ? configK - absHllArr.getNumAtCurMin() : configK;
     final double estimate;
     final double rseFactor;
     final boolean oooFlag = absHllArr.isOutOfOrderFlag();
     if (oooFlag) {
       estimate = absHllArr.getCompositeEstimate();
-      rseFactor = HLL_NON_HIP_RSE_FACTOR; //1.03896
+      rseFactor = HLL_NON_HIP_RSE_FACTOR;
     } else {
       estimate = absHllArr.getHipAccum();
-      rseFactor = HLL_HIP_RSE_FACTOR; //.8325546
+      rseFactor = HLL_HIP_RSE_FACTOR;
     }
 
     final double relErr = (lgConfigK > 12)
-        ? -(numStdDev * rseFactor) / Math.sqrt(configK)
-        : RelativeErrorTables.getRelErr(false, oooFlag, lgConfigK, numStdDev);
-    final double lb = Math.max(estimate * (1.0 + relErr), numNonZeros);
-    return lb;
+        ? (numStdDev * rseFactor) / Math.sqrt(configK)
+        : RelativeErrorTables.getRelErr(true, oooFlag, lgConfigK, numStdDev);
+    final double ub = estimate * (1.0 + relErr);
+    return ub;
   }
 
-  static final double hllUpperBound(final AbstractHllArray absHllArr, final int numStdDev) {
+  static final double hllLowerBound(final AbstractHllArray absHllArr, final int numStdDev) {
     final int lgConfigK = absHllArr.lgConfigK;
     final int configK = 1 << lgConfigK;
+    final double numNonZeros =
+        (absHllArr.getCurMin() == 0) ? configK - absHllArr.getNumAtCurMin() : configK;
     final double estimate;
     final double rseFactor;
     final boolean oooFlag = absHllArr.isOutOfOrderFlag();
     if (oooFlag) {
       estimate = absHllArr.getCompositeEstimate();
-      rseFactor = HLL_NON_HIP_RSE_FACTOR;
+      rseFactor = HLL_NON_HIP_RSE_FACTOR; //1.03896
     } else {
       estimate = absHllArr.getHipAccum();
-      rseFactor = HLL_HIP_RSE_FACTOR;
+      rseFactor = HLL_HIP_RSE_FACTOR; //.8325546
     }
 
     final double relErr = (lgConfigK > 12)
-        ? (numStdDev * rseFactor) / Math.sqrt(configK)
-        : RelativeErrorTables.getRelErr(true, oooFlag, lgConfigK, numStdDev);
-    final double ub = estimate * (1.0 + relErr);
-    return ub;
+        ? -(numStdDev * rseFactor) / Math.sqrt(configK)
+        : RelativeErrorTables.getRelErr(false, oooFlag, lgConfigK, numStdDev);
+    final double lb = Math.max(estimate * (1.0 + relErr), numNonZeros);
+    return lb;
   }
 
   //THE HLL COMPOSITE ESTIMATOR


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org