The function takes as input a 1D array of data. To make a plot with this function, plt.plot(x, y, marker='.', linestyle='none')
def ecdf(data):
"""Compute ECDF for a one-dimensional array of measurements.
source: DataCamp Statistical Thinking in Python Part 1
"""
# Number of data points: n
n = len(data)
# x-data for the ECDF: x
x = np.sort(data)
# y-data for the ECDF: y
y = np.arange(1, len(x)+1) / n
return x, y