【发布时间】:2019-01-12 01:59:21
【问题描述】:
我需要在不使用模块的情况下转换矩阵,只需使用例如 for 循环遍历它。
我有一个矩阵:
listoflist=[[1,2,3],[4,5,6],[7,8,9]]
例如:
1 minus the mean of row[1,2,3]
2 minus the mean of row[4,5,6]
3 minus the mean of row[7,8,9]
然后,用新值打印一个新矩阵。
有人可以帮帮我吗?
我需要从 row(x) 和 column(y) 中选择每个元素减去它的行平均值。
我不能导入除“math”以外的任何模块
【问题讨论】:
-
您在哪个部分遇到了问题?你知道如何求一列数字的均值吗?你知道如何迭代列表列表吗?您对这个问题的表述如此广泛,以至于如果不为您做功课,很难知道如何提供帮助。
-
还有……你有没有尝试过?
-
你也可以在github.com/python/cpython/blob/master/Lib/statistics.py查看统计模块的平均实现
标签: python python-3.x matrix