Created
March 22, 2019 15:16
-
-
Save cmantas/c8a1974931af5329a1e3d30ab563ab4c to your computer and use it in GitHub Desktop.
Revisions
-
cmantas created this gist
Mar 22, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ def cdf(data, label, show = True): data_size=len(data) # Set bins edges data_set=sorted(set(data)) bins=np.append(data_set, data_set[-1]+1) # Use the histogram function to bin the data counts, bin_edges = np.histogram(data, bins=bins, density=False) counts=counts.astype(float)/data_size # Find the cdf cdf = np.cumsum(counts) # Plot the cdf plt.plot(bin_edges[0:-1], cdf,linestyle='--', label=label) plt.ylabel('cdf') plt.legend() plt.show()