python 采用numpy计算描述性统计量

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))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值