20 #ifndef BOUNDS_ON_RATIOS_IN_SAMPLED_SETS_HPP_
21 #define BOUNDS_ON_RATIOS_IN_SAMPLED_SETS_HPP_
27 #include "bounds_binomial_proportions.hpp"
45 static constexpr
double NUM_STD_DEVS = 2.0;
57 check_inputs(a, b, f);
58 if (a == 0)
return 0.0;
59 if (f == 1.0)
return static_cast<double>(b) /
static_cast<double>(a);
71 check_inputs(a, b, f);
72 if (a == 0)
return 1.0;
73 if (f == 1.0)
return static_cast<double>(b) /
static_cast<double>(a);
84 check_inputs(a, b, 0.3);
85 if (a == 0)
return 0.5;
86 return static_cast<double>(b) /
static_cast<double>(a);
96 check_inputs(a, 1, f);
107 check_inputs(b + 1, b, f);
120 static double hacky_adjuster(
double f) {
121 const double tmp = sqrt(1.0 - f);
122 return (f <= 0.5) ? tmp : tmp + (0.01 * (f - 0.5));
125 static void check_inputs(uint64_t a, uint64_t b,
double f) {
127 throw std::invalid_argument(
"a must be >= b: a = " + std::to_string(a) +
", b = " + std::to_string(b));
129 if ((f > 1.0) || (f <= 0.0)) {
130 throw std::invalid_argument(
"Required: ((f <= 1.0) && (f > 0.0)): " + std::to_string(f));
static double approximate_upper_bound_on_p(uint64_t n, uint64_t k, double num_std_devs)
Computes upper bound of approximate Clopper-Pearson confidence interval for a binomial proportion.
Definition: bounds_binomial_proportions.hpp:148
static double approximate_lower_bound_on_p(uint64_t n, uint64_t k, double num_std_devs)
Computes lower bound of approximate Clopper-Pearson confidence interval for a binomial proportion.
Definition: bounds_binomial_proportions.hpp:113
Bounds on ratios in sampled sets.
Definition: bounds_on_ratios_in_sampled_sets.hpp:43
static double get_estimate_of_b_over_a(uint64_t a, uint64_t b)
Return the estimate of b over a.
Definition: bounds_on_ratios_in_sampled_sets.hpp:83
static double estimate_of_b(uint64_t b, double f)
Return the estimate of B.
Definition: bounds_on_ratios_in_sampled_sets.hpp:106
static double upper_bound_for_b_over_a(uint64_t a, uint64_t b, double f)
Return the approximate upper bound based on a 95% confidence interval.
Definition: bounds_on_ratios_in_sampled_sets.hpp:70
static double estimate_of_a(uint64_t a, double f)
Return the estimate of A.
Definition: bounds_on_ratios_in_sampled_sets.hpp:95
static double lower_bound_for_b_over_a(uint64_t a, uint64_t b, double f)
Return the approximate lower bound based on a 95% confidence interval.
Definition: bounds_on_ratios_in_sampled_sets.hpp:56
DataSketches namespace.
Definition: binomial_bounds.hpp:38