习题9.4
1.代码实现
点击查看代码
import numpy as np
from scipy.stats import f_oneway
data = [
[173, 172, 173, 174, 176, 178, 177, 179, 176, 172, 173, 174],
[175, 173, 176, 178, 177, 179, 174, 175, 173, 170, 171, 172],
[177, 175, 176, 174, 174, 175, 174, 173, 174, 169, 169, 170]
]
A1 = data[0][:3] + data[1][3:6] + data[2][6:9]
A2 = data[0][3:6] + data[1][6:9] + data[2][9:12]
A3 = data[0][6:9] + data[1][9:12] + data[2][:3]
B1 = data[0][:3] + data[0][3:6] + data[0][6:9]
B2 = data[1][:3] + data[1][3:6] + data[1][6:9]
B3 = data[2][:3] + data[2][3:6] + data[2][6:9]
B4 = [data[0][9:12], data[1][9:12], data[2][9:12]]
B4 = [item for sublist in B4 for item in sublist]
# 品种因素
f_value_variety, p_value_variety = f_oneway(A1, A2, A3)
# 化肥因素
f_value_fertilizer, p_value_fertilizer = f_oneway(B1, B2, B3, B4)
print("品种因素:")
print("F值:", f_value_variety)
print("P值:", p_value_variety)
print("化肥因素:")
print("F值:", f_value_fertilizer)
print("P值:", p_value_fertilizer)
print("3014")
2.运行结果