NumPy Statistical Distribution Display

Source: Internet
Author: User

#Guide PackageImportNumPy as NP#Import Iris Data fromSklearn.datasetsImportLoad_irisdata=Load_iris () Pental_len= data.data[:,2]Print(Pental_len)#calculates the maximum, average, median, mean variance of the flower petal lengthPrint("Maximum value:", Np.max (Pental_len))Print("Average:", Np.mean (Pental_len))Print("Medium Value:", Np.median (Pental_len))Print("mean variance:", NP.STD (Pental_len))#generates a random array of normal distributions with np.random.normal () and displays#Normal DistributionImportNumPy as NPImportMatplotlib.pyplot as PLTMU= 2#expected to be 2Sigma = 3#standard deviation is 3num = 1000#number is 10000Rand_data =Np.random.normal (MU, sigma, num) count, bins, ignored= Plt.hist (Rand_data, normed=True) Plt.plot (bins,1/(Sigma * NP.SQRT (2 * np.pi)) *np.exp (-(BINS-MU) **2/(2 * sigma**2)), linewidth=2, color='R') plt.show ()#Np.random.randn () produces a random array of normal distributions and displays itDATA=NP.RANDOM.RANDN (50)Print(Data)#Normal distribution graph showing iris petal length, graph, scatter plot#Normal distribution DiagramImportNumPy as NPImportMatplotlib.pyplot as PLTMU=Np.mean (Pental_len) Sigma=np.std (pental_len) Num=99999Rand_data=Np.random.normal (Mu,sigma,num) count, bins, ignored= Plt.hist (Rand_data, normed=True) Plt.plot (bins,1/(Sigma * NP.SQRT (2 * np.pi)) *np.exp (-(BINS-MU) **2/(2 * sigma**2)), linewidth=2, color='R') plt.show ()#Graph #Plt.plot (Np.linspace (1,150,num=150), Pental_len,'C') plt.show ()#Scatter Chart #Plt.scatter (Np.linspace (0,150,num=150), pental_len,alpha=0.5,marker='4') plt.show ()

NumPy Statistical Distribution Display

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.