0

I am not an expert at math but need to use this for a research project. I've been trying to plot the CDF using Python for a set of example data, of unknown distribution. The small example set I used was - [1.5, 1.5, 2.5, 3.5, 3.5, 3.5, 4.5, 5.5, 5.5, 6, 7]

I tried calculating the pdf myself and then plotting a step graph and also cummulative histogram, but I don't get an accurate graph with the two. All of the other methods I looked up happen to be working with normal distribution. Is that a necessity? Or is there a way to plot a CDF without knowing the distribution of the data?

khelwood
  • 55,782
  • 14
  • 81
  • 108
  • Does this answer your question? [Calculate the Cumulative Distribution Function (CDF) in Python](https://stackoverflow.com/questions/24788200/calculate-the-cumulative-distribution-function-cdf-in-python) – duffymo Feb 24 '20 at 16:38
  • 1
    You may want to look into [kernel density estimation](https://en.wikipedia.org/wiki/Kernel_density_estimation). SciPy has functionality for computing the KDE of a sample. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.gaussian_kde.html – Mark Dickinson Feb 24 '20 at 18:59
  • 1
    See also https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.kde.html which has an example similar to yours. `s = pd.Series([1.5, 1.5, 2.5, 3.5, 3.5, 3.5, 4.5, 5.5, 5.5, 6, 7]); s.plot.kde(); plt.show()` – JohanC Feb 25 '20 at 00:18

0 Answers0