统计与优化之方差分析作业

2.抽查某地区三所小学五年级男学生的身高,测得数据如下表(单位:厘米)
加粗样式**

对于这样一道题目,如果靠手机计算器去计算那些数据,简直能把人给累死,我使用numpy来对数据进行计算,具体辅助计算代码如下:
import numpy as np

x = np.array([[128.1, 134.1, 131.1, 138.9, 140.8, 127.4],
[150.3, 147.9, 136.8, 126.0, 150.7, 155.8],
[140.6, 143.1, 144.5, 143.7, 148.5, 146.4]])
print(x.shape)

x_mean_1 = np.around(np.mean(x, axis=1), 2)
x_mean = np.around(x.mean(), 2)

print(x_mean_1)
print(x_mean)

sa = np.around(np.sum(np.square(x_mean_1 - x_mean))*6, 2)
print(sa)

x_mean_1 = x_mean_1.reshape((3, 1))

se = np.around(np.sum(np.square(x - x_mean_1)), 2)
print(se)

完整答案:
在这里插入图片描述

3、 对四种不同的纺织机器采用三种不同的加压水平,对每种加压水平和每台机器作一
次试验,测得纱支强度如下表
在这里插入图片描述

仍旧采用numpy辅助计算,如果用计算器的话,我同学说算了一小时没算完,下面是辅助代码:
import numpy as np

x = np.array([[1577, 1690, 1800, 1642],
[1535, 1640, 1780, 1621],
[1592, 1652, 1810, 1663]])
a = x.shape[0]
b = x.shape[1]
print(a, b)

xipot_mean = np.around(np.mean(x, axis=1), 2)
xpotj_mean = np.around(np.mean(x, axis=0), 2)
x_mean = np.around(np.mean(x), 2)
print(xipot_mean, xpotj_mean, x_mean)
print(xpotj_mean - x_mean)

sa = np.around(b * np.sum(np.square(xipot_mean - x_mean)), 2)
sb = np.around(a * np.sum(np.square(xpotj_mean - x_mean)), 2)
print(sa, sb)

xipot_mean.resize((len(xipot_mean), 1))

se = np.sum(np.square(x - xipot_mean - xpotj_mean + x_mean))
print(np.around(se, 2))
st = sa + sb + se
print(st)
s1_square = np.around(sa/(a - 1), 2)
s2_square = np.around(sb/(b - 1), 2)
s3_square = np.around(se/(a*b - a - b + 1), 2)

fa = np.around(s1_square/s3_square, 2)

fb = np.around(s2_square/s3_square, 2)
print(s1_square, s2_square, s3_square, fa, fb)
完整的答案:

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱学习的贝塔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值