9951 explained code solutions for 126 technologies


python-numpyHow to calculate quantile from Numpy array


import numpy as np
arr = np.array([1,2,3,6,7,8,10,11,12,15,16,17])

q10 = np.quantile(arr,.10)
q50 = np.quantile(arr,.5)
q95 = np.quantile(arr,.95)ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array

np.quantile

calculate quantile of a given array on a given level

q10

0.1 quanile

q50

0.5 quantile (same as average)

q95

0.95 quantile