Python handles PDF and CDF

Source: Internet
Author: User

One of the most necessary things to do when you get the data is to look at your data distribution. The distribution of data also includes two types: PDF and CDF.

Here's how to generate PDFs and CDF using Python:

    1. Use the Matplotlib Drawing Interface hist () to directly draw the PDF distribution;
    2. Using NumPy's data processing function histogram (), the PDF distribution data can be generated to facilitate subsequent data processing, such as the further generation of CDF;
    3. The advantage of using Seaborn's Distplot () is that you can fit the PDF distribution to see the distribution type of your data;

Shown is a PDF graph generated using 3 algorithms. Here is the source code.

 fromSciPyImportStatsImportMatplotlib.pyplot as PltImportNumPy as NPImportSeaborn as Snsarr= Np.random.normal (size=100)#Plot histogramPlt.subplot (221) plt.hist (arr)#Obtain histogram dataPlt.subplot (222) hist, Bin_edges=Np.histogram (arr) Plt.plot (hist)#Fit Histogram curvePlt.subplot (223) Sns.distplot (arr, KDE=false, Fit=stats.gamma, rug=True) plt.show ()

Python handles PDF and CDF

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.