summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/lib/function_base.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index dee64c671..03019f1b5 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -4084,7 +4084,7 @@ def percentile(a,
array([7., 2.])
>>> assert not np.all(a == b)
- The different types of interpolation can be visualized graphically:
+ The different methods can be visualized graphically:
.. plot::
@@ -4094,20 +4094,25 @@ def percentile(a,
p = np.linspace(0, 100, 6001)
ax = plt.gca()
lines = [
- ('linear', None),
- ('higher', '--'),
- ('lower', '--'),
- ('nearest', '-.'),
- ('midpoint', '-.'),
- ]
- for interpolation, style in lines:
+ ('linear', '-', 'C0'),
+ ('inverted_cdf', ':', 'C1'),
+ # Almost the same as `inverted_cdf`:
+ ('averaged_inverted_cdf', '-.', 'C1'),
+ ('closest_observation', ':', 'C2'),
+ ('interpolated_inverted_cdf', '--', 'C1'),
+ ('hazen', '--', 'C3'),
+ ('weibull', '-.', 'C4'),
+ ('median_unbiased', '--', 'C5'),
+ ('normal_unbiased', '-.', 'C6'),
+ ]
+ for method, style, color in lines:
ax.plot(
- p, np.percentile(a, p, interpolation=interpolation),
- label=interpolation, linestyle=style)
+ p, np.percentile(a, p, method=method),
+ label=method, linestyle=style, color=color)
ax.set(
- title='Result for the data: ' + str(a),
+ title='Percentiles for different methods and data: ' + str(a),
xlabel='Percentile',
- ylabel='List item returned',
+ ylabel='Estimated percentile value',
yticks=a)
ax.legend()
plt.show()
@@ -4347,6 +4352,8 @@ def quantile(a,
array([7., 2.])
>>> assert not np.all(a == b)
+ See also `numpy.percentile` for a visualization of most methods.
+
References
----------
.. [1] R. J. Hyndman and Y. Fan,