pub struct QuantogramBuilder { /* private fields */ }Expand description
A fluent API Builder for Quantograms.
If error, growth or bins_per_doubling are changed, the other two are modified to be consistent with it. If error or growth imply a non-integral value for bins_per_doubling, take the ceiling of the derived bins_per_ceiling and rederive the other two from that, to satisfy a minimum guarantee.
No values may cause bins_per_doubling to exceed 1000, hence the error may not be set lower than 0.0347%.
Example of creating a Quantogram with a maximum of 2% absolute relative error:
use quantogram::QuantogramBuilder; let q = QuantogramBuilder().with_error(0.02).build();
This is the number of bins used for various error rates:
Bins Error Rate
---- ----------
2 17.2 %
3 11.5 %
4 8.6 %
5 6.9 %
7 4.9 %
12 2.9 %
18 1.9 %
35 1.0 %
70 0.5 %
139 0.25%
347 0.10%
694 0.05%
867 0.04%
1000 0.0347%Implementations§
Source§impl QuantogramBuilder
impl QuantogramBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder that defaults to an error rate of 1% with 35 bins per doubling and a growth factor of 1.02.
Sourcepub fn build(self) -> Quantogram
pub fn build(self) -> Quantogram
Build a Quantogram using the collected configuration values.
pub fn with_hsm_cache(self, hsm_cache: &HalfSampleModeCache) -> Self
Sourcepub fn with_smallest_power(self, power: isize) -> Self
pub fn with_smallest_power(self, power: isize) -> Self
Configure the underflow of samples. A sample whose magnitude has a power of two less than the given values will be set to zero.
Example: If you only need to compute quantiles to two decimal places:
set power = -7, since 2^-7 = 1/128 < 0.01.Sourcepub fn with_largest_power(self, power: isize) -> Self
pub fn with_largest_power(self, power: isize) -> Self
Configure the overflow of samples. A sample whose magnitude has a power of two greater than the given values will be set to +/- Infinity.
Example: If you only need to study numbers below a thousand, set power = 10, since 2^10 = 1024 > 1000.
Sourcepub fn with_error(self, error: f64) -> Self
pub fn with_error(self, error: f64) -> Self
Configure to target the given maximum absolute relative error.
Sourcepub fn with_growth(self, growth: f64) -> Self
pub fn with_growth(self, growth: f64) -> Self
Configure to target the given growth factor from one bucket to the next. This will be adjusted to the nearest value that is an Nth root of 2.
Sourcepub fn with_bins_per_doubling(self, bins: usize) -> Self
pub fn with_bins_per_doubling(self, bins: usize) -> Self
Set bins_per_doubling, error, and growth to be consistent with the given value. Memory usage is proportional to this value, so this is the way to directly control memory usage. A bins_per_doubling value of 35 yields 1% error.
Trait Implementations§
Source§impl Clone for QuantogramBuilder
impl Clone for QuantogramBuilder
Source§fn clone(&self) -> QuantogramBuilder
fn clone(&self) -> QuantogramBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more