Function smartnoise_runtime::components::quantile::quantile[][src]

pub fn quantile<T: FromPrimitive + Ord + Clone + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Add<Output = T> + Rem<Output = T> + ToPrimitive>(
    data: ArrayD<T>,
    alpha: f64,
    interpolation: &str
) -> Result<ArrayD<T>>

Accepts data and returns desired quantile of each column in the data.

Arguments

Return

Quantile of interest for each column of your data.

Example

use ndarray::prelude::*;
use smartnoise_runtime::components::quantile::quantile;
use noisy_float::types::n64;
use smartnoise_validator::Float;
let data: ArrayD<Float> = arr2(&[ [0., 1., 2.], [2., 3., 4.] ]).into_dyn();
let median = quantile(data.mapv(|v| n64(v as f64)), 0.5, &"midpoint".to_string()).unwrap();
println!("{:?}", median);
assert_eq!(median, arr1(& [1.0, 2.0, 3.0] ).into_dyn().mapv(|v| n64(v as f64)));