@@ -10,25 +10,25 @@ pub mod interpolate {
10
10
use num_traits:: { FromPrimitive , ToPrimitive } ;
11
11
use std:: ops:: { Add , Div } ;
12
12
13
- /// Used to provide an interpolation strategy to [`percentile_axis_mut `].
13
+ /// Used to provide an interpolation strategy to [`quantile_axis_mut `].
14
14
///
15
- /// [`percentile_axis_mut `]: ../trait.PercentileExt .html#tymethod.percentile_axis_mut
15
+ /// [`quantile_axis_mut `]: ../trait.QuantileExt .html#tymethod.quantile_axis_mut
16
16
pub trait Interpolate < T > {
17
17
#[ doc( hidden) ]
18
- fn float_percentile_index ( q : f64 , len : usize ) -> f64 {
18
+ fn float_quantile_index ( q : f64 , len : usize ) -> f64 {
19
19
( ( len - 1 ) as f64 ) * q
20
20
}
21
21
#[ doc( hidden) ]
22
22
fn lower_index ( q : f64 , len : usize ) -> usize {
23
- Self :: float_percentile_index ( q, len) . floor ( ) as usize
23
+ Self :: float_quantile_index ( q, len) . floor ( ) as usize
24
24
}
25
25
#[ doc( hidden) ]
26
26
fn higher_index ( q : f64 , len : usize ) -> usize {
27
- Self :: float_percentile_index ( q, len) . ceil ( ) as usize
27
+ Self :: float_quantile_index ( q, len) . ceil ( ) as usize
28
28
}
29
29
#[ doc( hidden) ]
30
- fn float_percentile_index_fraction ( q : f64 , len : usize ) -> f64 {
31
- Self :: float_percentile_index ( q, len) . fract ( )
30
+ fn float_quantile_index_fraction ( q : f64 , len : usize ) -> f64 {
31
+ Self :: float_quantile_index ( q, len) . fract ( )
32
32
}
33
33
#[ doc( hidden) ]
34
34
fn needs_lower ( q : f64 , len : usize ) -> bool ;
@@ -94,7 +94,7 @@ pub mod interpolate {
94
94
95
95
impl < T > Interpolate < T > for Nearest {
96
96
fn needs_lower ( q : f64 , len : usize ) -> bool {
97
- <Self as Interpolate < T > >:: float_percentile_index_fraction ( q, len) < 0.5
97
+ <Self as Interpolate < T > >:: float_quantile_index_fraction ( q, len) < 0.5
98
98
}
99
99
fn needs_higher ( q : f64 , len : usize ) -> bool {
100
100
!<Self as Interpolate < T > >:: needs_lower ( q, len)
@@ -156,7 +156,7 @@ pub mod interpolate {
156
156
where
157
157
D : Dimension ,
158
158
{
159
- let fraction = <Self as Interpolate < T > >:: float_percentile_index_fraction ( q, len) ;
159
+ let fraction = <Self as Interpolate < T > >:: float_quantile_index_fraction ( q, len) ;
160
160
let mut a = lower. unwrap ( ) ;
161
161
let b = higher. unwrap ( ) ;
162
162
azip ! ( mut a, ref b in {
@@ -169,8 +169,8 @@ pub mod interpolate {
169
169
}
170
170
}
171
171
172
- /// Percentile methods.
173
- pub trait PercentileExt < A , S , D >
172
+ /// Quantile methods.
173
+ pub trait QuantileExt < A , S , D >
174
174
where
175
175
S : Data < Elem = A > ,
176
176
D : Dimension ,
@@ -231,24 +231,24 @@ where
231
231
A : MaybeNan ,
232
232
A :: NotNan : Ord ;
233
233
234
- /// Return the qth percentile of the data along the specified axis.
234
+ /// Return the qth quantile of the data along the specified axis.
235
235
///
236
236
/// `q` needs to be a float between 0 and 1, bounds included.
237
- /// The qth percentile for a 1-dimensional lane of length `N` is defined
237
+ /// The qth quantile for a 1-dimensional lane of length `N` is defined
238
238
/// as the element that would be indexed as `(N-1)q` if the lane were to be sorted
239
239
/// in increasing order.
240
- /// If `(N-1)q` is not an integer the desired percentile lies between
240
+ /// If `(N-1)q` is not an integer the desired quantile lies between
241
241
/// two data points: we return the lower, nearest, higher or interpolated
242
242
/// value depending on the type `Interpolate` bound `I`.
243
243
///
244
244
/// Some examples:
245
245
/// - `q=0.` returns the minimum along each 1-dimensional lane;
246
246
/// - `q=0.5` returns the median along each 1-dimensional lane;
247
247
/// - `q=1.` returns the maximum along each 1-dimensional lane.
248
- /// (`q=0` and `q=1` are considered improper percentiles )
248
+ /// (`q=0` and `q=1` are considered improper quantiles )
249
249
///
250
250
/// The array is shuffled **in place** along each 1-dimensional lane in
251
- /// order to produce the required percentile without allocating a copy
251
+ /// order to produce the required quantile without allocating a copy
252
252
/// of the original array. Each 1-dimensional lane is shuffled independently
253
253
/// from the others.
254
254
/// No assumptions should be made on the ordering of the array elements
@@ -261,17 +261,17 @@ where
261
261
///
262
262
/// **Panics** if `axis` is out of bounds or if `q` is not between
263
263
/// `0.` and `1.` (inclusive).
264
- fn percentile_axis_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
264
+ fn quantile_axis_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
265
265
where
266
266
D : RemoveAxis ,
267
267
A : Ord + Clone ,
268
268
S : DataMut ,
269
269
I : Interpolate < A > ;
270
270
271
- /// Return the `q`th percentile of the data along the specified axis, skipping NaN values.
271
+ /// Return the `q`th quantile of the data along the specified axis, skipping NaN values.
272
272
///
273
- /// See [`percentile_axis_mut `](##tymethod.percentile_axis_mut ) for details.
274
- fn percentile_axis_skipnan_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
273
+ /// See [`quantile_axis_mut `](##tymethod.quantile_axis_mut ) for details.
274
+ fn quantile_axis_skipnan_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
275
275
where
276
276
D : RemoveAxis ,
277
277
A : MaybeNan ,
@@ -280,7 +280,7 @@ where
280
280
I : Interpolate < A :: NotNan > ;
281
281
}
282
282
283
- impl < A , S , D > PercentileExt < A , S , D > for ArrayBase < S , D >
283
+ impl < A , S , D > QuantileExt < A , S , D > for ArrayBase < S , D >
284
284
where
285
285
S : Data < Elem = A > ,
286
286
D : Dimension ,
@@ -357,7 +357,7 @@ where
357
357
} ) )
358
358
}
359
359
360
- fn percentile_axis_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
360
+ fn quantile_axis_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
361
361
where
362
362
D : RemoveAxis ,
363
363
A : Ord + Clone ,
@@ -387,7 +387,7 @@ where
387
387
I :: interpolate ( lower, higher, q, axis_len)
388
388
}
389
389
390
- fn percentile_axis_skipnan_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
390
+ fn quantile_axis_skipnan_mut < I > ( & mut self , axis : Axis , q : f64 ) -> Array < A , D :: Smaller >
391
391
where
392
392
D : RemoveAxis ,
393
393
A : MaybeNan ,
@@ -402,7 +402,7 @@ where
402
402
} else {
403
403
Some (
404
404
not_nan
405
- . percentile_axis_mut :: < I > ( Axis ( 0 ) , q)
405
+ . quantile_axis_mut :: < I > ( Axis ( 0 ) , q)
406
406
. into_raw_vec ( )
407
407
. remove ( 0 ) ,
408
408
)
0 commit comments