0

I have got an sorted array of integers and I want to plot a Cumulative Distribution Function for it. However , the nature of data is uncertain , so I think I cannot use any predefined library for it.

So to implement it , I have used interpolation function (scipy.interpolate). I am doing it like this :

def plot_cdf(self,x,y,):
        tck = interpolate.splrep(x,y,s=0)
        y = interpolate.splev(x,tck,der=0)
        plt.figure()
        plt.plot(x,y)
        xlabel("Percentage")
        ylabel("Unavailability slot duration")
        plt.show()

Can it be improved??? Is there any predefined function for it????

Manish
  • 71
  • 3
  • 10
  • What do you mean with "the nature of data is uncertain"? Also, what's the point of `xnew` here, since it remains equal to `x`? – Junuxx Jun 18 '12 at 14:27
  • hey this code is a snippet and I mean data can/cant fit into any distribution. – Manish Jun 18 '12 at 14:34
  • possible duplicate of [How to plot empirical cdf in matplotlib in Python?](http://stackoverflow.com/questions/3209362/how-to-plot-empirical-cdf-in-matplotlib-in-python) – Dave Feb 04 '15 at 15:34

1 Answers1

0

You plot functions with plot, which is what you are using.

ninjagecko
  • 88,546
  • 24
  • 137
  • 145