我知道statsmodels.tools.tools.ECDF,但是由于计算empricial累积分布函数(ECDF)是非常直接的,而且我希望最小化项目中的依赖项,所以我希望手动编写它。
在给定的list()/np.array()Pandas.Series中,每个元素的ECDF可以计算为given in Wikipedia:
下面是Pandas数据框dfser,我想得到values列的ecdf。文中还给出了两个一次线性解。
有没有更快的方法可以做到这一点?速度在我的应用程序中很重要。# Note that in my case indices are unique identifiers so I cannot reset them.
import numpy as np
import pandas as pd
# all indices are unique, but there may be duplicate measurement values (that belong to different indices).
dfser = pd.DataFrame({'group':['a','b','b','a','d','c','e','e','c','a','b','d','d','c','d','e','e','a'],
'values':[2.01899E-06, 1.12186E-07, 8.97467E-07, 2.91257E-06