基于两个矩阵找出调和均值并将结果存储在第三个矩阵中
Finding out harmonic means based on two matrices and store results in third matrix
我有两个矩阵a和b
a = matrix(1:4,ncol=2)
b = matrix(5:8,ncol=2)
现在我想找出这些的调和均值并放入第三个矩阵。
一个例子:-
x = a[1,1],y = b[1,1] then harmonic mean of x and y = 2*x*y/(x+y)
期望的输出:-
c = matrix(c(1.666667,4.2,3,5.333333),ncol = 2)
你不能把 a 和 b 代入你的等式吗:
c <- 2*a*b/(a+b)
输出
[,1] [,2]
[1,] 1.666667 4.200000
[2,] 3.000000 5.333333
由于算术运算符在矩阵上按元素计算应该是:
2*x*y/(x+y)
.. 或明显的替代。
我有两个矩阵a和b
a = matrix(1:4,ncol=2)
b = matrix(5:8,ncol=2)
现在我想找出这些的调和均值并放入第三个矩阵。
一个例子:-
x = a[1,1],y = b[1,1] then harmonic mean of x and y = 2*x*y/(x+y)
期望的输出:-
c = matrix(c(1.666667,4.2,3,5.333333),ncol = 2)
你不能把 a 和 b 代入你的等式吗:
c <- 2*a*b/(a+b)
输出
[,1] [,2]
[1,] 1.666667 4.200000
[2,] 3.000000 5.333333
由于算术运算符在矩阵上按元素计算应该是:
2*x*y/(x+y)
.. 或明显的替代。