Exercise 4.4: Understanding and building ECDFs



As a reminder, the empirical cumulative distribution function for a set of data point evaluated at x is

ECDF(x) = fraction of data points ≤ x.

Write a function with call signature

ecdf_vals(data)

which takes a one-dimensional NumPy array of data and returns the x and y values for plotting a “dot-style” ECDF. That is, each dot has a y value given by the ECDF evaluated at x.

When writing a function, you should have detailed doc strings and checking of input. However, here the focus is on your understanding of ECDFs and developing skills with NumPy, so you do not need to have a very descriptive doc string nor lots of input checking.

Hint: The functions np.sort() and np.arange() may be useful.