Last active
April 6, 2022 16:16
-
-
Save rsokl/f882e74ef16cdd22a9e12ac438f8ff50 to your computer and use it in GitHub Desktop.
ecdf : empirical cumulative distribution function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def ecdf(data): | |
"""Returns (x) the sorted data and (y) the empirical cumulative-proportion | |
of each datum. | |
Parameters | |
---------- | |
data : numpy.ndarray, size-N | |
Returns | |
------- | |
Tuple[numpy.ndarray shape-(N,), numpy.ndarray shape-(N,)] | |
Sorted data, empirical CDF values""" | |
data = np.asarray(data).ravel() | |
y = np.linspace(1 / len(data), 1, len(data)) | |
x = np.sort(data) | |
return x, y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment