探索棒球数据
由于均值和中位数相差很大,您决定向 MLB 投诉。他们找到了错误,并把更正后的数据发给了您。数据仍以 2D NumPy 数组 np_baseball 提供,含 3 列。
编辑器中的 Python 脚本已包含用于打印不同汇总统计量及其说明的信息代码,并且已将 numpy 以 np 导入。您能完成剩下的部分吗?np_baseball 已可用。
本练习是课程的一部分
Python 入门
练习说明
- 打印平均身高的代码已给出。请补全打印身高中位数的代码。
- 在
np_baseball的第 1 列上使用np.std(),计算stddev。 - 个子高的球员是否更重?使用
np.corrcoef(),将np_baseball第 1 列与第 2 列之间的相关系数存入corr。
交互式实操练习
通过完成这段示例代码来试试这个练习。
avg = np.mean(np_baseball[:,0])
print("Average: " + str(avg))
# Print median height
med = ____
print("Median: " + str(med))
# Print out the standard deviation on height
stddev = ____
print("Standard Deviation: " + str(stddev))
# Print out correlation between first and second column
corr = ____
print("Correlation: " + str(corr))