Skip to content

Commit f7911c6

Browse files
committed
DOC: Refer to the quantile/percentile notes for nan versions
1 parent 1574011 commit f7911c6

File tree

2 files changed

+4
-201
lines changed

2 files changed

+4
-201
lines changed

numpy/lib/function_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3893,7 +3893,7 @@ def percentile(a,
38933893
`a` after this function completes is undefined.
38943894
interpolation : str, optional
38953895
This parameter specifies the interpolation method to
3896-
use when the desired quantile lies between two data points
3896+
use when the desired percentile lies between two data points
38973897
There are many different methods, some unique to NumPy. See the
38983898
notes for explanation. Options
38993899

numpy/lib/nanfunctions.py

Lines changed: 3 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ def nanpercentile(
12691269
undefined.
12701270
interpolation : str, optional
12711271
This parameter specifies the interpolation method to use when the
1272-
desired quantile lies between two data points There are many
1272+
desired percentile lies between two data points There are many
12731273
different methods, some unique to NumPy. See the notes for
12741274
explanation. Options:
12751275
@@ -1325,100 +1325,7 @@ def nanpercentile(
13251325
13261326
Notes
13271327
-----
1328-
Given a vector ``V`` of length ``N``, the ``q``-th percentile of ``V``
1329-
is the value ``q/100`` of the way from the minimum to the maximum in a
1330-
sorted copy of ``V``. The values and distances of the two nearest
1331-
neighbors as well as the `interpolation` parameter will determine the
1332-
percentile if the normalized ranking does not match the location of
1333-
``q`` exactly. This function is the same as the median if ``q=50``, the
1334-
same as the minimum if ``q=0`` and the same as the maximum if
1335-
``q=100``.
1336-
1337-
This optional `interpolation` parameter specifies the interpolation
1338-
method to use when the desired quantile lies between two data points
1339-
``i < j``. If ``g`` is the fractional part of the index surrounded by
1340-
``i`` and alpha and beta are correction constants modifying i and j.
1341-
1342-
.. math::
1343-
i + g = (q - alpha) / ( n - alpha - beta + 1 )
1344-
1345-
The different interpolation methods then work as follows
1346-
1347-
inverted_cdf:
1348-
method 1 of H&F [1]_.
1349-
This method gives discontinuous results:
1350-
* if g > 0 ; then take j
1351-
* if g = 0 ; then take i
1352-
1353-
averaged_inverted_cdf:
1354-
method 2 of H&F [1]_.
1355-
This method give discontinuous results:
1356-
* if g > 0 ; then take j
1357-
* if g = 0 ; then average between bounds
1358-
1359-
closest_observation:
1360-
method 3 of H&F [1]_.
1361-
This method give discontinuous results:
1362-
* if g > 0 ; then take j
1363-
* if g = 0 and index is odd ; then take j
1364-
* if g = 0 and index is even ; then take i
1365-
1366-
interpolated_inverted_cdf:
1367-
method 4 of H&F [1]_.
1368-
This method give continuous results using:
1369-
* alpha = 0
1370-
* beta = 1
1371-
1372-
hazen:
1373-
method 5 of H&F [1]_.
1374-
This method give continuous results using:
1375-
* alpha = 1/2
1376-
* beta = 1/2
1377-
1378-
weibull:
1379-
method 6 of H&F [1]_.
1380-
This method give continuous results using:
1381-
* alpha = 0
1382-
* beta = 0
1383-
1384-
inclusive:
1385-
Default method, aliased with "linear".
1386-
method 7 of H&F [1]_.
1387-
This method give continuous results using:
1388-
* alpha = 1
1389-
* beta = 1
1390-
1391-
median_unbiased:
1392-
method 8 of H&F [1]_.
1393-
This method is probably the best method if the sample
1394-
distribution function is unknown (see reference).
1395-
This method give continuous results using:
1396-
* alpha = 1/3
1397-
* beta = 1/3
1398-
1399-
normal_unbiased:
1400-
method 9 of H&F [1]_.
1401-
This method is probably the best method if the sample
1402-
distribution function is known to be normal.
1403-
This method give continuous results using:
1404-
* alpha = 3/8
1405-
* beta = 3/8
1406-
1407-
lower:
1408-
NumPy method kept for backwards compatibility.
1409-
Takes ``i`` as the interpolation point.
1410-
1411-
higher:
1412-
NumPy method kept for backwards compatibility.
1413-
Takes ``j`` as the interpolation point.
1414-
1415-
nearest:
1416-
NumPy method kept for backwards compatibility.
1417-
Takes ``i`` or ``j``, whichever is nearest.
1418-
1419-
midpoint:
1420-
NumPy method kept for backwards compatibility.
1421-
Uses ``(i + j) / 2``.
1328+
For more information please see `numpy.percentile`
14221329
14231330
Examples
14241331
--------
@@ -1448,12 +1355,6 @@ def nanpercentile(
14481355
array([7., 2.])
14491356
>>> assert not np.all(a==b)
14501357
1451-
References
1452-
----------
1453-
.. [1] R. J. Hyndman and Y. Fan,
1454-
"Sample quantiles in statistical packages,"
1455-
The American Statistician, 50(4), pp. 361-365, 1996
1456-
14571358
"""
14581359
a = np.asanyarray(a)
14591360
q = np.true_divide(q, 100.0)
@@ -1565,99 +1466,7 @@ def nanquantile(
15651466
15661467
Notes
15671468
-----
1568-
Given a vector ``V`` of length ``N``, the q-th quantile of ``V`` is the
1569-
value ``q`` of the way from the minimum to the maximum in a sorted copy of
1570-
``V``. The values and distances of the two nearest neighbors as well as the
1571-
`interpolation` parameter will determine the quantile if the normalized
1572-
ranking does not match the location of ``q`` exactly. This function is the
1573-
same as the median if ``q=0.5``, the same as the minimum if ``q=0.0`` and
1574-
the same as the maximum if ``q=1.0``.
1575-
1576-
This optional `interpolation` parameter specifies the interpolation method
1577-
to use when the desired quantile lies between two data points ``i < j``. If
1578-
``g`` is the fractional part of the index surrounded by ``i`` and alpha
1579-
and beta are correction constants modifying i and j.
1580-
1581-
.. math::
1582-
i + g = (q - alpha) / ( n - alpha - beta + 1 )
1583-
1584-
The different interpolation methods then work as follows
1585-
1586-
inverted_cdf:
1587-
method 1 of H&F [1]_.
1588-
This method gives discontinuous results:
1589-
* if g > 0 ; then take j
1590-
* if g = 0 ; then take i
1591-
1592-
averaged_inverted_cdf:
1593-
method 2 of H&F [1]_.
1594-
This method give discontinuous results:
1595-
* if g > 0 ; then take j
1596-
* if g = 0 ; then average between bounds
1597-
1598-
closest_observation:
1599-
method 3 of H&F [1]_.
1600-
This method give discontinuous results:
1601-
* if g > 0 ; then take j
1602-
* if g = 0 and index is odd ; then take j
1603-
* if g = 0 and index is even ; then take i
1604-
1605-
interpolated_inverted_cdf:
1606-
method 4 of H&F [1]_.
1607-
This method give continuous results using:
1608-
* alpha = 0
1609-
* beta = 1
1610-
1611-
hazen:
1612-
method 5 of H&F [1]_.
1613-
This method give continuous results using:
1614-
* alpha = 1/2
1615-
* beta = 1/2
1616-
1617-
weibull:
1618-
method 6 of H&F [1]_.
1619-
This method give continuous results using:
1620-
* alpha = 0
1621-
* beta = 0
1622-
1623-
inclusive:
1624-
Default method, aliased with "linear".
1625-
method 7 of H&F [1]_.
1626-
This method give continuous results using:
1627-
* alpha = 1
1628-
* beta = 1
1629-
1630-
median_unbiased:
1631-
method 8 of H&F [1]_.
1632-
This method is probably the best method if the sample
1633-
distribution function is unknown (see reference).
1634-
This method give continuous results using:
1635-
* alpha = 1/3
1636-
* beta = 1/3
1637-
1638-
normal_unbiased:
1639-
method 9 of H&F [1]_.
1640-
This method is probably the best method if the sample
1641-
distribution function is known to be normal.
1642-
This method give continuous results using:
1643-
* alpha = 3/8
1644-
* beta = 3/8
1645-
1646-
lower:
1647-
NumPy method kept for backwards compatibility.
1648-
Takes ``i`` as the interpolation point.
1649-
1650-
higher:
1651-
NumPy method kept for backwards compatibility.
1652-
Takes ``j`` as the interpolation point.
1653-
1654-
nearest:
1655-
NumPy method kept for backwards compatibility.
1656-
Takes ``i`` or ``j``, whichever is nearest.
1657-
1658-
midpoint:
1659-
NumPy method kept for backwards compatibility.
1660-
Uses ``(i + j) / 2``.
1469+
For more information please see `numpy.quantile`
16611470
16621471
Examples
16631472
--------
@@ -1686,12 +1495,6 @@ def nanquantile(
16861495
array([7., 2.])
16871496
>>> assert not np.all(a==b)
16881497
1689-
References
1690-
----------
1691-
.. [1] R. J. Hyndman and Y. Fan,
1692-
"Sample quantiles in statistical packages,"
1693-
The American Statistician, 50(4), pp. 361-365, 1996
1694-
16951498
"""
16961499
a = np.asanyarray(a)
16971500
q = np.asanyarray(q)

0 commit comments

Comments
 (0)