You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2022/01/11 00:54:45 UTC
[datasketches-cpp] branch kll_inclusive_rank updated: test inclusive PMF and CDF
This is an automated email from the ASF dual-hosted git repository.
alsay pushed a commit to branch kll_inclusive_rank
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
The following commit(s) were added to refs/heads/kll_inclusive_rank by this push:
new 310da28 test inclusive PMF and CDF
310da28 is described below
commit 310da2898c3cef14f5d81795004721405d9bd2af
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Jan 10 16:54:21 2022 -0800
test inclusive PMF and CDF
---
kll/test/kll_sketch_test.cpp | 44 +++++++++++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 13 deletions(-)
diff --git a/kll/test/kll_sketch_test.cpp b/kll/test/kll_sketch_test.cpp
index 5da33bc..b2e2b96 100644
--- a/kll/test/kll_sketch_test.cpp
+++ b/kll/test/kll_sketch_test.cpp
@@ -245,20 +245,38 @@ TEST_CASE("kll sketch", "[kll_sketch]") {
sketch.update(static_cast<float>(i));
values[i] = static_cast<float>(i);
}
-
- const auto ranks(sketch.get_CDF(values, n));
- const auto pmf(sketch.get_PMF(values, n));
-
- double subtotal_pmf(0);
- for (int i = 0; i < n; i++) {
- if (sketch.get_rank(values[i]) != ranks[i]) {
- std::cerr << "checking rank vs CDF for value " << i << std::endl;
- REQUIRE(sketch.get_rank(values[i]) == ranks[i]);
+ { // inclusive=false (default)
+ const auto ranks(sketch.get_CDF(values, n));
+ const auto pmf(sketch.get_PMF(values, n));
+
+ double subtotal_pmf = 0;
+ for (int i = 0; i < n; i++) {
+ if (sketch.get_rank(values[i]) != ranks[i]) {
+ std::cerr << "checking rank vs CDF for value " << i << std::endl;
+ REQUIRE(sketch.get_rank(values[i]) == ranks[i]);
+ }
+ subtotal_pmf += pmf[i];
+ if (abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
+ std::cerr << "CDF vs PMF for value " << i << std::endl;
+ REQUIRE(ranks[i] == Approx(subtotal_pmf).margin(NUMERIC_NOISE_TOLERANCE));
+ }
}
- subtotal_pmf += pmf[i];
- if (abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
- std::cerr << "CDF vs PMF for value " << i << std::endl;
- REQUIRE(ranks[i] == Approx(subtotal_pmf).margin(NUMERIC_NOISE_TOLERANCE));
+ }
+ { // inclusive=true
+ const auto ranks(sketch.get_CDF<true>(values, n));
+ const auto pmf(sketch.get_PMF<true>(values, n));
+
+ double subtotal_pmf = 0;
+ for (int i = 0; i < n; i++) {
+ if (sketch.get_rank<true>(values[i]) != ranks[i]) {
+ std::cerr << "checking rank vs CDF for value " << i << std::endl;
+ REQUIRE(sketch.get_rank(values[i]) == ranks[i]);
+ }
+ subtotal_pmf += pmf[i];
+ if (abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
+ std::cerr << "CDF vs PMF for value " << i << std::endl;
+ REQUIRE(ranks[i] == Approx(subtotal_pmf).margin(NUMERIC_NOISE_TOLERANCE));
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org