8000 DOC: Update percentile/quantile docs · lithomas1/numpy@7d8a8e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d8a8e7

Browse files
committed
DOC: Update percentile/quantile docs
Mainly fixes the method list slightly, tones down the warning a bit and fixes the link to the paper (I did not realize that the link failed to work due only because the reference was missing from nanquantile/nanpercentile).
1 parent 5bd71fb commit 7d8a8e7

File tree

2 files changed

+72
-60
lines changed

2 files changed

+72
-60
lines changed

numpy/lib/function_base.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3898,21 +3898,21 @@ def percentile(a,
38983898
method : str, optional
38993899
This parameter specifies the method to use for estimating the
39003900
percentile. There are many different methods, some unique to NumPy.
3901-
See the notes for explanation. The options aligning with the R types
3902-
and the H&F paper are:
3903-
3904-
* (H&F 1): 'inverted_cdf'
3905-
* (H&F 2): 'averaged_inverted_cdf'
3906-
* (H&F 3): 'closest_observation'
3907-
* (H&F 4): 'interpolated_inverted_cdf'
3908-
* (H&F 5): 'hazen'
3909-
* (H&F 6): 'weibull'
3910-
* (H&F 7): 'linear' (default)
3911-
* (H&F 8): 'median_unbiased'
3912-
* (H&F 9): 'normal_unbiased'
3913-
3914-
Mainly for compatibility reasons, NumPy also supports the following
3915-
options which appear to be unique to NumPy:
3901+
See the notes for explanation. The options sorted by their R type
3902+
as summarized in the H&F paper [1]_ are:
3903+
3904+
1. 'inverted_cdf'
3905+
2. 'averaged_inverted_cdf'
3906+
3. 'closest_observation'
3907+
4. 'interpolated_inverted_cdf'
3908+
5. 'hazen'
3909+
6. 'weibull'
3910+
7. 'linear' (default)
3911+
8. 'median_unbiased'
3912+
9. 'normal_unbiased'
3913+
3914+
The first three methods are discontiuous. NumPy further defines the
3915+
following discontinuous variations of the default 'linear' (7.) option:
39163916
39173917
* 'lower'
39183918
* 'higher',
@@ -4177,21 +4177,21 @@ def quantile(a,
41774177
method : str, optional
41784178
This parameter specifies the method to use for estimating the
41794179
quantile. There are many different methods, some unique to NumPy.
4180-
See the notes for explanation. The options aligning with the R types
4181-
and the H&F paper are:
4182-
4183-
* (H&F 1): 'inverted_cdf'
4184-
* (H&F 2): 'averaged_inverted_cdf'
4185-
* (H&F 3): 'closest_observation'
4186-
* (H&F 4): 'interpolated_inverted_cdf'
4187-
* (H&F 5): 'hazen'
4188-
* (H&F 6): 'weibull'
4189-
* (H&F 7): 'linear' (default)
4190-
* (H&F 8): 'median_unbiased'
4191-
* (H&F 9): 'normal_unbiased'
4192-
4193-
Mainly for compatibility reasons, NumPy also supports the following
4194-
options which appear to be unique to NumPy:
4180+
See the notes for explanation. The options sorted by their R type
4181+
as summarized in the H&F paper [1]_ are:
4182+
4183+
1. 'inverted_cdf'
4184+
2. 'averaged_inverted_cdf'
4185+
3. 'closest_observation'
4186+
4. 'interpolated_inverted_cdf'
4187+
5. 'hazen'
4188+
6. 'weibull'
4189+
7. 'linear' (default)
4190+
8. 'median_unbiased'
4191+
9. 'normal_unbiased'
4192+
4193+
The first three methods are discontiuous. NumPy further defines the
4194+
following discontinuous variations of the default 'linear' (7.) option:
41954195
41964196
* 'lower'
41974197
* 'higher',

numpy/lib/nanfunctions.py

Lines changed: 42 additions & 30 deletions
6D40
Original file line numberDiff line numberDiff line change
@@ -1273,21 +1273,21 @@ def nanpercentile(
12731273
method : str, optional
12741274
This parameter specifies the method to use for estimating the
12751275
percentile. There are many different methods, some unique to NumPy.
1276-
See the notes for explanation. The options aligning with the R types
1277-
and the H&F paper are:
1278-
1279-
* (H&F 1): 'inverted_cdf'
1280-
* (H&F 2): 'averaged_inverted_cdf'
1281-
* (H&F 3): 'closest_observation'
1282-
* (H&F 4): 'interpolated_inverted_cdf'
1283-
* (H&F 5): 'hazen'
1284-
* (H&F 6): 'weibull'
1285-
* (H&F 7): 'linear' (default)
1286-
* (H&F 8): 'median_unbiased'
1287-
* (H&F 9): 'normal_unbiased'
1288-
1289-
Mainly for compatibility reasons, NumPy also supports the following
1290-
options which appear to be unique to NumPy:
1276+
See the notes for explanation. The options sorted by their R type
1277+
as summarized in the H&F paper [1]_ are:
1278+
1279+
1. 'inverted_cdf'
1280+
2. 'averaged_inverted_cdf'
1281+
3. 'closest_observation'
1282+
4. 'interpolated_inverted_cdf'
1283+
5. 'hazen'
1284+
6. 'weibull'
1285+
7. 'linear' (default)
1286+
8. 'median_unbiased'
1287+
9. 'normal_unbiased'
1288+
1289+
The first three methods are discontiuous. NumPy further defines the
1290+
following discontinuous variations of the default 'linear' (7.) option:
12911291
12921292
* 'lower'
12931293
* 'higher',
@@ -1365,6 +1365,12 @@ def nanpercentile(
13651365
array([7., 2.])
13661366
>>> assert not np.all(a==b)
13671367
1368+
References
1369+
----------
1370+
.. [1] R. J. Hyndman and Y. Fan,
1371+
"Sample quantiles in statistical packages,"
1372+
The American Statistician, 50(4), pp. 361-365, 1996
1373+
13681374
"""
13691375
if interpolation is not None:
13701376
method = function_base._check_interpolation_as_method(
@@ -1427,21 +1433,21 @@ def nanquantile(
14271433
method : str, optional
14281434
This parameter specifies the method to use for estimating the
14291435
quantile. There are many different methods, some unique to NumPy.
1430-
See the notes for explanation. The options aligning with the R types
1431-
and the H&F paper are:
1432-
1433-
* (H&F 1): 'inverted_cdf'
1434-
* (H&F 2): 'averaged_inverted_cdf'
1435-
* (H&F 3): 'closest_observation'
1436-
* (H&F 4): 'interpolated_inverted_cdf'
1437-
* (H&F 5): 'hazen'
1438-
* (H&F 6): 'weibull'
1439-
* (H&F 7): 'linear' (default)
1440-
* (H&F 8): 'median_unbiased'
1441-
* (H&F 9): 'normal_unbiased'
1442-
1443-
Mainly for compatibility reasons, NumPy also supports the following
1444-
options which appear to be unique to NumPy:
1436+
See the notes for explanation. The options sorted by their R type
1437+
as summarized in the H&F paper [1]_ are:
1438+
1439+
1. 'inverted_cdf'
1440+
2. 'averaged_inverted_cdf'
1441+
3. 'closest_observation'
1442+
4. 'interpolated_inverted_cdf'
1443+
5. 'hazen'
1444+
6. 'weibull'
1445+
7. 'linear' (default)
1446+
8. 'median_unbiased'
1447+
9. 'normal_unbiased'
1448+
1449+
The first three methods are discontiuous. NumPy further defines the
1450+
following discontinuous variations of the default 'linear' (7.) option:
14451451
14461452
* 'lower'
14471453
* 'higher',
@@ -1518,6 +1524,12 @@ def nanquantile(
15181524
array([7., 2.])
15191525
>>> assert not np.all(a==b)
15201526
1527+
References
1528+
----------
1529+
.. [1] R. J. Hyndman and Y. Fan,
1530+
"Sample quantiles in statistical packages,"
1531+
The American Statistician, 50(4), pp. 361-365, 1996
1532+
15211533
"""
15221534
if interpolation is not None:
15231535
method = function_base._check_interpolation_as_method(

0 commit comments

Comments
 (0)
0