ECDFs stat Empirical cumulative distribution functions

In this exercise, you will write a function that takes as input a 1D array of data and then returns the x and y values of the ECDF.  ECDFs are among the most important plots in statistical analysis. You can write your own function, foo(x,y) according to the following skeleton:

The function foo() above takes two arguments a and b and returns two values x and y. The function header def foo(a,b): contains the function signaturefoo(a,b), which consists of the function name, along with its parameters.

 

Define a function with the signature ecdf(data). Within the function definition,

  • Compute the number of data points, n, using the len() function.
  • The xx-values are the sorted data. Use the np.sort() function to perform the sorting.
  • The yy data of the ECDF go from 1/n to 1 in equally spaced increments. You can construct this using np.arange() and then dividing by n.
  • The function returns the values x and y.