相关疑难解决方法(0)

如何计算R中向量的欧几里德范数?

我试过了norm,但我认为它给出了错误的结果.(规范c(1, 2, 3)sqrt(1*1+2*2+3*3),但它返回6..

x1 <- 1:3
norm(x1)
# Error in norm(x1) : 'A' must be a numeric matrix
norm(as.matrix(x1))
# [1] 6
as.matrix(x1)
#      [,1]
# [1,]    1
# [2,]    2
# [3,]    3
norm(as.matrix(x1))
# [1] 6
Run Code Online (Sandbox Code Playgroud)

有谁知道在R中计算向量范数的函数是什么?

statistics r vector

37
推荐指数
4
解决办法
8万
查看次数

4
推荐指数
2
解决办法
3593
查看次数

标签 统计

r ×2

cross-product ×1

statistics ×1

vector ×1