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