I'm trying to implement the empirical distribution function from a paper that has the MATLAB implementation on page 3. Here's my Python version of it.
I converted it according to the NumPy for MATLAB users documentation while taking into account how statsmodels
implements ECDF
from statsmodels.distributions.empirical_distribution import ECDF
def ecdf_representation(D, n):
"""calculate ECDF from D at n points"""
m = np.mean(D)
X = []
for d in xrange(D.shape[0] + 1):
func = ECDF([D[:, d] + np.random.randn(np.shape(D[:, d])) * 0.01])
ll = func(np.linspace(0, 1, n))
X = [X, ll]
X = [X, m]
plt.plot(X)
plt.show()
return X
I get the error:
line 25, in ecdf_representation
func = ECDF([D[:, d] + np.random.randn(np.shape(D[:, d]))])
IndexError: too many indices for array
Doesn't D.shape[0]
return the number of columns? So, D[:, d]
should work right? What's going on here?