NumPy Statistical Distribution Display

Source: Internet
Author: User





as NP from sklearn.datasets import Load_irisdata=load_iris () petal_length=numpy.array (List (len[2] for in data['data')#取出花瓣长度数据print (Np.max (petal_length)) #花瓣长度最大值print ( Np.mean (Petal_length)) #花瓣长度平均值print (NP.STD (petal_length)) #花瓣长度的中值print (Np.median (petal_length)) #花瓣长度的均方差

Operation Result:

Np.random.normal (1,5,100)# generates a random array of normal distributions with np.random.normal () and displays

Operation Result:

NP.RANDOM.RANDN (3, 3) Np.random.randn ()# produces a random array of normal distributions and displays them. 

The result of the operation is:

# Normal distribution graph showing the length of iris petals Import NumPy as NP Import Matplotlib.pyplot as Pltmu=Np.mean (petal_length) Sigma=np.std (petal_length) num=10000  = np.random.normal (mu, sigma, num)= plt.hist (Rand_data, normed="  R") plt.show ()

The result of the operation is:

# graph showing the length of iris petals plt.plot (np.linspace (0,150,num=150), petal_length,'y') Plt.show ()

The result of the operation is:

# scatter plot showing the length of iris petals Import NumPy as NP Import Matplotlib.pyplot as Pltplt.scatter (np.linspace (0,150,num=150), petal_length,alpha=0.5,marker=' h ', color='y') plt.show ()

The result of the operation is:

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.