Created
November 27, 2021 05:31
-
-
Save axjack/4e684dc279f5af7f2ff1616eef4bfb92 to your computer and use it in GitHub Desktop.
問23.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------- | |
# 第23章 判別分析 | |
# 問23.2 p.213 | |
# ------------- | |
# データ | |
LD1 <- c(-0.1,-0.1,0.2,0.4,0.9) | |
LD2 <- c(0.0,0.2,-0.2,0.9,-0.3) | |
x1 <- c(1.2,1.4,0.3,6.0,4.6) | |
x2 <- c(1.4,1.4,0.3,0.7,2.1) | |
x3 <- c(0.8,0.2,1.6,3.6,9.2) | |
xL <- c(2.5,-1.1,0,-0.8,1.0) | |
# 射影後の座標 | |
f <- function(x){ | |
c(LD1 %*% x,LD2 %*% x) | |
} | |
# 距離計算 | |
matrix( c(f(x1),f(x2),f(x3),f(xL)), byrow = T, ncol=2 ) |> dist() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
となるので、新しいサンプルから最も近い重心を持つクラスは、x2すなわちクラスFの群となる。