Trait rustml::scaling::ScaleVector
[−]
[src]
pub trait ScaleVector<T> { fn scale_by(&self, g: &Vec<Gaussian<T>>) -> Vec<T>; }
Trait to scale a vector.
Required Methods
fn scale_by(&self, g: &Vec<Gaussian<T>>) -> Vec<T>
Scales the values of the vector by the parameters provided
by the vector g
.
For each value the following is done: the value at index i
is
subtracted by the mean
of the Gaussian
at index i
and the result is divided by the
standard deviation of the Gaussian
at index i
. This is done
for each value in the vector and a new vector is returned with
the result.
Example
use rustml::scaling::*; use rustml::gaussian::*; let gaussians = vec![ Gaussian::new(2.0, 4.0), Gaussian::new(5.0, 16.0) ]; assert_eq!( [4.0, 7.0].scale_by(&gaussians), vec![ (4.0 - 2.0) / 2.0, (7.0 - 5.0) / 4.0 ] );
Implementors
impl ScaleVector<f32> for Vec<f32>
impl ScaleVector<f32> for [f32]
impl ScaleVector<f64> for Vec<f64>
impl ScaleVector<f64> for [f64]