QuantogramBuilder

Struct QuantogramBuilder 

Source
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

Source

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.

Source

pub fn build(self) -> Quantogram

Build a Quantogram using the collected configuration values.

Source

pub fn with_hsm_cache(self, hsm_cache: &HalfSampleModeCache) -> Self

Source

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.
Source

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.

Source

pub fn with_error(self, error: f64) -> Self

Configure to target the given maximum absolute relative error.

Source

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.

Source

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

Source§

fn clone(&self) -> QuantogramBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QuantogramBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for QuantogramBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V