np.quantile
时间: 2023-10-19 20:09:55 浏览: 79
`np.quantile` is a NumPy function that computes the quantiles of an array. A quantile is a value that divides a dataset into equal proportions. For example, the median is the 50th percentile, meaning that it divides the dataset into two equal parts.
The `np.quantile` function takes three arguments: the array to compute the quantiles for, the percentile(s) to compute, and an optional axis argument to specify the axis along which to compute the quantiles.
Here's an example usage:
```python
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
# Compute the 25th, 50th, and 75th percentiles
q1, q2, q3 = np.quantile(arr, [0.25, 0.5, 0.75])
print(q1) # Output: 3.25
print(q2) # Output: 5.5
print(q3) # Output: 7.75
```
This example computes the 25th, 50th, and 75th percentiles (also known as the first, second, and third quartiles) of an array of numbers.
阅读全文