numpy-均值、中值、标准差、方差、百分位数、随机数
import numpy speed = [99,86,87,88,111,86,103,87,94,78,77,85,86] x = numpy.mean(speed)#均值 print(x)
x = numpy.median(speed) #中值 x = numpy.std(speed) #标准差 x = numpy.var(speed) #方差 x = numpy.percentile(ages, 75) #百分位数 x = numpy.random.uniform(0.0, 5.0, 250)#随机数在0到5之间,一共250个
scipy-众数
from scipy import stats speed = [99,86,87,88,111,86,103,87,94,78,77,85,86] x = stats.mode(speed) #众数 print(x)
Matplotlib-绘图
hist() 方法-直方图:
import numpy import matplotlib.pyplot as plt #正态分布:随机数平均值为 5.0,标准差为 1.0,一共100000个 x = numpy.random.normal(5.0, 1.0, 100000) plt.hist(x, 100) #绘制100条柱状图 plt.show()
scatter() 方法-散点图:
import matplotlib.pyplot as plt x = [5,7,8,7,2,17,2,9,4,11,12,9,6] y = [99,86,87,88,111,86,103,87,94,78,77,85,86] plt.scatter(x, y) plt.show()
scipy-线性回归线
未完