pub struct ScalarQuantizationParameters { /* private fields */ }Expand description
Parameters controlling the generation of the scalar quantization Quantizer.
When performing scalar quantization, the mean of each dimension will be calculated and the dataset will be shifted around this mean.
Next, the standard deviation of each dimension will be computed and the maximum m found.
The dynamic range of the final compressed encoding will then span
2 * standard_deviations * m for each dimension symmetrically about the mean for each
dimension. Values outside the spanned dynamic range will be clamped.
Implementations§
Source§impl ScalarQuantizationParameters
impl ScalarQuantizationParameters
Sourcepub fn new(standard_deviations: Positive<f64>) -> Self
pub fn new(standard_deviations: Positive<f64>) -> Self
Construct a new quantizer with the given parameters.
§Arguments
-
standard_deviations: The number of maximal standard deviations to use for the encoding’s dynamic range. This number must be positive, and generally should be greater than 1.0.A good starting value is generally 2.0.
Sourcepub fn standard_deviations(&self) -> Positive<f64>
pub fn standard_deviations(&self) -> Positive<f64>
Return the current number of standard deviations being used to set the dynamic range.
Sourcepub fn train<T>(&self, data: MatrixView<'_, T>) -> ScalarQuantizer
pub fn train<T>(&self, data: MatrixView<'_, T>) -> ScalarQuantizer
Train a new ScalarQuantizer on the input training data.
The training algoritm works as follows:
-
The medoid of the training data is computed.
-
The standard deviation for each dimension is then calculated across all rows of the training set.
-
The maximum standard deviation
sis computed and the dynamic rangedynof the quantizer is computed asdyn = 2.0 * self.standard_deviations() * s. -
The quantizer is then constructed with
scale = dyn / (2.pow(NBITS) - 1).
§Complexity
This method is linear in the number of rows and columns in data.
§Allocates
This method allocated memory on the order of data.ncols() (the dimensionality of
the data).
§Parallelism
This function is single threaded.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScalarQuantizationParameters
impl RefUnwindSafe for ScalarQuantizationParameters
impl Send for ScalarQuantizationParameters
impl Sync for ScalarQuantizationParameters
impl Unpin for ScalarQuantizationParameters
impl UnwindSafe for ScalarQuantizationParameters
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more