import numpy
# 计算均值
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
print("原始数据为{}".format(speed))
x1 = numpy.mean(speed)
print("均值为{}".format(x1))
# 计算中值
x2 = numpy.median(speed)
print("中值为{}".format(x2))
# 计算众数
from scipy import stats
x3 = stats.mode(speed)
print("众数为{}".format(x3.mode))
# 计算方差
x4 = numpy.var(speed)
print("方差为{}".format(x4))
# 计算标准差
x5 = numpy.std(speed)
print("标准差为{}".format(x5))
# 计算百分位数
x_25 = numpy.percentile(speed, 25)
x_75 = numpy.percentile(speed, 75)
x_90 = numpy.percentile(speed, 90)
print("第25百分位数{}".format(x_25))
print("第75百分位数{}".format(x_75))
print("第90百分位数{}".format(x_90))
# 计算最大值、最小值
x_min = numpy.min(speed)
print("最小值为{}".format(x_min))
x_max = numpy.max(speed)
print("最大值为{}".format(x_max))
python 采用numpy计算描述性统计量
于 2025-10-22 19:50:55 首次发布
1649

被折叠的 条评论
为什么被折叠?



