Not a ready-made function but a compact and reasonably fast snippet:

(a<value).mean()

You can (at least on my machine) squeeze out a few percent better performance by using np.count_nonzero

np.count_nonzero(a<value) / a.size

but tbh I wouldn't even bother.

Answer from loopy walt on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v2.5 Manual
If q is a single probability and axis=None, then the result is a scalar. If multiple probability levels are given, first axis of the result corresponds to the quantiles. The other axes are the axes that remain after the reduction of a. If the input contains integers or floats smaller than float64, ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-quantile-in-python
numpy.quantile() in Python - GeeksforGeeks
April 22, 2025 - Example 4: In this example, we calculate the 50th percentile (median) of a 1D array and store the result in an existing array res using the out parameter of numpy.quantile().
🌐
Python Pool
pythonpool.com › home › numpy › numpy quantile(): q, axis, method, nan, and examples
Numpy Quantile() Explained With Examples - Python Pool
July 13, 2026 - If you omit axis, NumPy flattens the whole array first. That may be correct for a global summary, but it is not a per-column result. Use axis=1 to calculate quantiles across each row.
People also ask

How do I ignore NaN values in a quantile?
Use numpy.nanquantile() when NaN values should be excluded from the calculation rather than propagated.
🌐
pythonpool.com
pythonpool.com › home › numpy › numpy quantile(): q, axis, method, nan, and examples
Numpy Quantile() Explained With Examples - Python Pool
What is the difference between quantile() and percentile()?
They express the same idea with different scales: quantile uses q from 0 to 1, while percentile uses values from 0 to 100.
🌐
pythonpool.com
pythonpool.com › home › numpy › numpy quantile(): q, axis, method, nan, and examples
Numpy Quantile() Explained With Examples - Python Pool
Why does the method argument matter?
Different estimators interpolate or select sample values differently; choose and document the method when reproducibility or statistical interpretation matters.
🌐
pythonpool.com
pythonpool.com › home › numpy › numpy quantile(): q, axis, method, nan, and examples
Numpy Quantile() Explained With Examples - Python Pool
🌐
ProgramCreek
programcreek.com › python › example › 125382 › numpy.quantile
Python Examples of numpy.quantile
Formula: (25th percentile + 2*50th percentile + 75th percentile)/4 Parameters ---------- data : array-like an iterable, either a list or a numpy array Returns ------- the trimean: float """ q1 = np.quantile(data, 0.25) q3 = np.quantile(data, 0.75) median = np.median(data) return (q1 + 2*median ...
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v2.1 Manual
An array of weights associated with the values in a. Each value in a contributes to the quantile according to its associated weight. The weights array can either be 1-D (in which case its length must be the size of a along the given axis) or of the same shape as a.
🌐
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .quantile()
Python:NumPy | Built-in Functions | .quantile() | Codecademy
April 19, 2025 - The .quantile() function in NumPy ... separate a data set into equal probabilities. For example, the 25th quantile is the point which 25% of the data set falls below....
🌐
Statistics Globe
statisticsglobe.com › home › python programming language for statistics & data science › quantile of numpy array in python (example) | get quartile with np.quantile function
Quantile of NumPy Array in Python | Get Quartile with np.quantile Function
March 22, 2023 - This example demonstrates how to calculate the quartiles of a NumPy array. For this task, we can apply the quantile function in combination with the arange function. Within the arange function, we have to specify the intervals of our quantiles (i.e.
Find elsewhere
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v2.6.dev0 Manual
If q is a single probability and axis=None, then the result is a scalar. If multiple probability levels are given, first axis of the result corresponds to the quantiles. The other axes are the axes that remain after the reduction of a. If the input contains integers, the output data-type is float64.
🌐
Skytowner
skytowner.com › explore › numpy_quantile_method
NumPy | quantile method with Examples
Numpy's quantile(~) method returns the interpolated value at the specified quantile. Note that this method is exactly the same as the percentile(~), just that the quantile(~) method takes a value between 0 and 1 - not 0 and 100.
🌐
Programiz
programiz.com › python-programming › numpy › methods › quantile
NumPy quantile()
In NumPy, the quantile() function computes the q-th quantile of data along the specified axis. The q-th quantile represents the value below which q percent of the data falls. For example, the 0.50th quantile (also known as the median) divides the data into two equal halves.
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v2.0 Manual
If q is a single probability and axis=None, then the result is a scalar. If multiple probability levels are given, first axis of the result corresponds to the quantiles. The other axes are the axes that remain after the reduction of a. If the input contains integers or floats smaller than float64, ...
🌐
NumPy
numpy.org › doc › 1.22 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v1.22 Manual
Given a vector V of length N, the q-th quantile of V is the value q of the way from the minimum to the maximum in a sorted copy of V. The values and distances of the two nearest neighbors as well as the method parameter will determine the quantile if the normalized ranking does not match the ...
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v2.2 Manual
If q is a single probability and axis=None, then the result is a scalar. If multiple probability levels are given, first axis of the result corresponds to the quantiles. The other axes are the axes that remain after the reduction of a. If the input contains integers or floats smaller than float64, ...
🌐
NumPy
numpy.org › doc › 1.21 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v1.21 Manual
June 22, 2021 - Given a vector V of length N, the q-th quantile of V is the value q of the way from the minimum to the maximum in a sorted copy of V. The values and distances of the two nearest neighbors as well as the interpolation parameter will determine the quantile if the normalized ranking does not match ...
🌐
SciPy
docs.scipy.org › doc › numpy-1.17.0 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v1.17 Manual
>>> a = np.array([[10, 7, 4], [3, 2, 1]]) >>> a array([[10, 7, 4], [ 3, 2, 1]]) >>> np.quantile(a, 0.5) 3.5 >>> np.quantile(a, 0.5, axis=0) array([6.5, 4.5, 2.5]) >>> np.quantile(a, 0.5, axis=1) array([7., 2.]) >>> np.quantile(a, 0.5, axis=1, keepdims=True) array([[7.], [2.]]) >>> m = np.quantile(a, 0.5, axis=0) >>> out = np.zeros_like(m) >>> np.quantile(a, 0.5, axis=0, out=out) array([6.5, 4.5, 2.5]) >>> m array([6.5, 4.5, 2.5]) >>> b = a.copy() >>> np.quantile(b, 0.5, axis=1, overwrite_input=True) array([7., 2.]) >>> assert not np.all(a == b) numpy.nanpercentile ·
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v2.3 Manual
If q is a single probability and axis=None, then the result is a scalar. If multiple probability levels are given, first axis of the result corresponds to the quantiles. The other axes are the axes that remain after the reduction of a. If the input contains integers or floats smaller than float64, ...
🌐
NumPy
numpy.org › doc › 1.19 › reference › generated › numpy.quantile.html
numpy.quantile — NumPy v1.19 Manual
June 29, 2020 - Given a vector V of length N, the q-th quantile of V is the value q of the way from the minimum to the maximum in a sorted copy of V. The values and distances of the two nearest neighbors as well as the interpolation parameter will determine the quantile if the normalized ranking does not match ...