简体   繁体   中英

How to plot cdf in python

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????

您可以使用plot绘制函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM