• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / datasketches-java / #306

30 Apr 2024 10:01PM UTC coverage: 97.645% (-0.5%) from 98.139%
#306

push

web-flow
Merge pull request #555 from apache/fix_pom_xml_header

Fix pom xml header

26865 of 27513 relevant lines covered (97.64%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.47
/src/main/java/org/apache/datasketches/hll/RelativeErrorTables.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.datasketches.hll;
21

22
/**
23
 * @author Lee Rhodes
24
 * @author Kevin Lang
25
 */
26
final class RelativeErrorTables {
×
27

28
  /**
29
   * Return Relative Error for UB or LB for HIP or Non-HIP as a function of numStdDev.
30
   * @param upperBound true if for upper bound
31
   * @param oooFlag true if for Non-HIP
32
   * @param lgK must be between 4 and 12 inclusive
33
   * @param stdDev must be between 1 and 3 inclusive
34
   * @return Relative Error for UB or LB for HIP or Non-HIP as a function of numStdDev.
35
   */
36
  static double getRelErr(final boolean upperBound, final boolean oooFlag,
37
      final int lgK, final int stdDev) {
38
    final int idx = ((lgK - 4) * 3) + (stdDev - 1);
1✔
39
    final int sw = (oooFlag ? 2 : 0) | (upperBound ? 1 : 0);
1✔
40
    double f = 0;
1✔
41
    switch (sw) {
1✔
42
      case 0 : { //HIP, LB
43
        f = HIP_LB[idx];
1✔
44
        break;
1✔
45
      }
46
      case 1 : { //HIP, UB
47
        f = HIP_UB[idx];
1✔
48
        break;
1✔
49
      }
50
      case 2 : { //NON_HIP, LB
51
        f = NON_HIP_LB[idx];
1✔
52
        break;
1✔
53
      }
54
      case 3 : { //NON_HIP, UB
55
        f = NON_HIP_UB[idx];
1✔
56
        break;
1✔
57
      }
58
      default: f = 0;//can't happen
×
59
    }
60
    return f;
1✔
61
  }
62

63
  //case 0
64
  private static double[] HIP_LB = //sd 1, 2, 3
1✔
65
    { //Q(.84134), Q(.97725), Q(.99865) respectively
66
      0.207316195, 0.502865572, 0.882303765, //4
67
      0.146981579, 0.335426881, 0.557052,    //5
68
      0.104026721, 0.227683872, 0.365888317, //6
69
      0.073614601, 0.156781585, 0.245740374, //7
70
      0.05205248,  0.108783763, 0.168030442, //8
71
      0.036770852, 0.075727545, 0.11593785,  //9
72
      0.025990219, 0.053145536, 0.080772263, //10
73
      0.018373987, 0.037266176, 0.056271814, //11
74
      0.012936253, 0.02613829,  0.039387631, //12
75
    };
76

77
  //case 1
78
  private static double[] HIP_UB = //sd 1, 2, 3
1✔
79
    { //Q(.15866), Q(.02275), Q(.00135) respectively
80
      -0.207805347, -0.355574279, -0.475535095, //4
81
      -0.146988328, -0.262390832, -0.360864026, //5
82
      -0.103877775, -0.191503663, -0.269311582, //6
83
      -0.073452978, -0.138513438, -0.198487447, //7
84
      -0.051982806, -0.099703123, -0.144128618, //8
85
      -0.036768609, -0.07138158,  -0.104430324, //9
86
      -0.025991325, -0.050854296, -0.0748143,   //10
87
      -0.01834533,  -0.036121138, -0.05327616,  //11
88
      -0.012920332, -0.025572893, -0.037896952, //12
89
    };
90

91
  //case 2
92
  private static double[] NON_HIP_LB = //sd 1, 2, 3
1✔
93
    { //Q(.84134), Q(.97725), Q(.99865) respectively
94
      0.254409839, 0.682266712, 1.304022158, //4
95
      0.181817353, 0.443389054, 0.778776219, //5
96
      0.129432281, 0.295782195, 0.49252279,  //6
97
      0.091640655, 0.201175925, 0.323664385, //7
98
      0.064858051, 0.138523393, 0.218805328, //8
99
      0.045851855, 0.095925072, 0.148635751, //9
100
      0.032454144, 0.067009668, 0.102660669, //10
101
      0.022921382, 0.046868565, 0.071307398, //11
102
      0.016155679, 0.032825719, 0.049677541  //12
103
    };
104

105
  //case 3
106
  private static double[] NON_HIP_UB = //sd 1, 2, 3
1✔
107
    { //Q(.15866), Q(.02275), Q(.00135) respectively
108
      -0.256980172, -0.411905944, -0.52651057,  //4
109
      -0.182332109, -0.310275547, -0.412660505, //5
110
      -0.129314228, -0.230142294, -0.315636197, //6
111
      -0.091584836, -0.16834013,  -0.236346847, //7
112
      -0.06487411,  -0.122045231, -0.174112107, //8
113
      -0.04591465,  -0.08784505,  -0.126917615, //9
114
      -0.032433119, -0.062897613, -0.091862929, //10
115
      -0.022960633, -0.044875401, -0.065736049, //11
116
      -0.016186662, -0.031827816, -0.046973459  //12
117
    };
118

119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc