NumPy Statistical Distribution Display

Source: Internet
Author: User

#计算鸢尾花花瓣长度的最大值, mean, median, mean variance. Import  as  np from sklearn.datasets import load_irisdata=Load_iris ( ) Iris=data.datapetal_length=iris[:,2]  #取所有行的第二列print (Np.mean (petal_length))  #平均值print (NP.STD (petal_length))   #标准差print (Np.median (petal_length))  #中位数print (Np.max (Petal_ Length) print (Np.min (petal_length))

#用np. Random.normal () produces a random array of normal distributions and displays them. Print (Np.random.normal (1,3,))

#np. RANDOM.RANDN () produces a random array of normal distributions and displays them. Print (Np.random.randn (3,3))  #3行3列正太分布随机数组print (Np.random.randn ( ))

#显示鸢尾花花瓣长度的正态分布图import Matplotlib.pyplot asPLTMU=Np.mean (petal_length) #期望sigma=np.std (petal_length) #标准差num= +#个数为1000rand_data=np.random.normal (mu,sigma,num) print (rand_data.shape) print (Type (rand_data)) print (Np.mean (petal_length), NP.STD (Petal_length), Np.median (petal_length)) 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 ()

#显示鸢尾花花瓣长度的曲线图mu=Np.mean (petal_length) #期望sigma=np.std (petal_length) #标准差print (Np.mean ( Petal_length), NP.STD (Petal_length), Np.median (petal_length)) count,bins,ignored=plt.hist (rand_data,30 , normed=True) plt.plot (np.linspace (0,num=),petal_length,'  R') plt.show ()

#显示鸢尾花花瓣长度的散点图. Mu=np.mean (petal_length) #期望sigma=np.std (petal_length) #标准差print (Np.mean (petal_length), NP.STD ( Petal_length), Np.median (petal_length)) Plt.scatter (np.linspace (0,num=), Petal_length,alpha=0.5, marker='D') 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.