Trait ndarray_stats::QuantileExt
source · pub trait QuantileExt<A, S, D>where
S: Data<Elem = A>,
D: Dimension,{
fn min(&self) -> Option<&A>
where
A: PartialOrd;
fn min_skipnan(&self) -> &A
where
A: MaybeNan,
A::NotNan: Ord;
fn max(&self) -> Option<&A>
where
A: PartialOrd;
fn max_skipnan(&self) -> &A
where
A: MaybeNan,
A::NotNan: Ord;
fn quantile_axis_mut<I>(&mut self, axis: Axis, q: f64) -> Array<A, D::Smaller>
where
D: RemoveAxis,
A: Ord + Clone,
S: DataMut,
I: Interpolate<A>;
fn quantile_axis_skipnan_mut<I>(
&mut self,
axis: Axis,
q: f64
) -> Array<A, D::Smaller>
where
D: RemoveAxis,
A: MaybeNan,
A::NotNan: Clone + Ord,
S: DataMut,
I: Interpolate<A::NotNan>;
}
Expand description
Quantile methods for ArrayBase
.
Required Methods
sourcefn min(&self) -> Option<&A>where
A: PartialOrd,
fn min(&self) -> Option<&A>where
A: PartialOrd,
Finds the elementwise minimum of the array.
Returns None
if any of the pairwise orderings tested by the function
are undefined. (For example, this occurs if there are any
floating-point NaN values in the array.)
Additionally, returns None
if the array is empty.
sourcefn min_skipnan(&self) -> &Awhere
A: MaybeNan,
A::NotNan: Ord,
fn min_skipnan(&self) -> &Awhere
A: MaybeNan,
A::NotNan: Ord,
Finds the elementwise minimum of the array, skipping NaN values.
Warning This method will return a NaN value if none of the values in the array are non-NaN values. Note that the NaN value might not be in the array.
sourcefn max(&self) -> Option<&A>where
A: PartialOrd,
fn max(&self) -> Option<&A>where
A: PartialOrd,
Finds the elementwise maximum of the array.
Returns None
if any of the pairwise orderings tested by the function
are undefined. (For example, this occurs if there are any
floating-point NaN values in the array.)
Additionally, returns None
if the array is empty.
sourcefn max_skipnan(&self) -> &Awhere
A: MaybeNan,
A::NotNan: Ord,
fn max_skipnan(&self) -> &Awhere
A: MaybeNan,
A::NotNan: Ord,
Finds the elementwise maximum of the array, skipping NaN values.
Warning This method will return a NaN value if none of the values in the array are non-NaN values. Note that the NaN value might not be in the array.
sourcefn quantile_axis_mut<I>(&mut self, axis: Axis, q: f64) -> Array<A, D::Smaller>where
D: RemoveAxis,
A: Ord + Clone,
S: DataMut,
I: Interpolate<A>,
fn quantile_axis_mut<I>(&mut self, axis: Axis, q: f64) -> Array<A, D::Smaller>where
D: RemoveAxis,
A: Ord + Clone,
S: DataMut,
I: Interpolate<A>,
Return the qth quantile of the data along the specified axis.
q
needs to be a float between 0 and 1, bounds included.
The qth quantile for a 1-dimensional lane of length N
is defined
as the element that would be indexed as (N-1)q
if the lane were to be sorted
in increasing order.
If (N-1)q
is not an integer the desired quantile lies between
two data points: we return the lower, nearest, higher or interpolated
value depending on the type Interpolate
bound I
.
Some examples:
q=0.
returns the minimum along each 1-dimensional lane;q=0.5
returns the median along each 1-dimensional lane;q=1.
returns the maximum along each 1-dimensional lane. (q=0
andq=1
are considered improper quantiles)
The array is shuffled in place along each 1-dimensional lane in order to produce the required quantile without allocating a copy of the original array. Each 1-dimensional lane is shuffled independently from the others. No assumptions should be made on the ordering of the array elements after this computation.
Complexity (quickselect):
- average case: O(
m
); - worst case: O(
m
^2); wherem
is the number of elements in the array.
Panics if axis
is out of bounds, if the axis has length 0, or if
q
is not between 0.
and 1.
(inclusive).
sourcefn quantile_axis_skipnan_mut<I>(
&mut self,
axis: Axis,
q: f64
) -> Array<A, D::Smaller>where
D: RemoveAxis,
A: MaybeNan,
A::NotNan: Clone + Ord,
S: DataMut,
I: Interpolate<A::NotNan>,
fn quantile_axis_skipnan_mut<I>(
&mut self,
axis: Axis,
q: f64
) -> Array<A, D::Smaller>where
D: RemoveAxis,
A: MaybeNan,
A::NotNan: Clone + Ord,
S: DataMut,
I: Interpolate<A::NotNan>,
Return the q
th quantile of the data along the specified axis, skipping NaN values.
See quantile_axis_mut
for details.