emanuele
emanuele

Reputation: 2589

Does exists an equivalent of `ecdf(x)(x)` of R in python?

I am struggling to find an equivalent of ecdf function of R, namely

x<-1:10
y<-ecdf(x)(x)

in Python. Does exists an equivalent of this function?

Upvotes: 0

Views: 82

Answers (2)

Warren Weckesser
Warren Weckesser

Reputation: 114811

Toby's suggestion to use the ECDF class in statsmodels is great. Here's an alternative that you could use if you don't want the dependency on statsmodels, but scipy is OK:

from scipy.stats import rankdata

y = rankdata(x, method='max')/float(len(x))

Upvotes: 1

Related Questions