#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