找到最小化二维网格上所有点的距离的点

时间:2018-06-05 10:03:35

标签: grid distance dimensions

我想计算一个网格上的点,它最小化了网格上代理的距离。

以下是输入。

正常分布的选民填充网格:

    N<- 100
    ID <- 1:N
    set.seed(1)
    x <- as.integer(rnorm(100,50,20))
    set.seed(1)
    y <- as.integer(rnorm(100,50,20)) 
    agent <- as.matrix(cbind(ID,x,y))

这两点是

ID[1] <- "Conservatives"
ID[2] <- "Labour"
y[1] <- 44.85   #conservatives
x[1] <- 70      #conservatives
y[2] <- 79.57   #Labour
x[2] <- 35.71   #Labour
matrix <- cbind(ID,x,y)
party <- as.matrix(cbind(ID,x,y))

因此,我需要的是点的坐标,它最小化了与代理的x和y坐标中所有点的欧几里德距离。任何人都可以帮我解决这个问题吗?我一直在寻找解决方案,但找不到我理解的解决方案,可以解决我的问题。

感谢您的帮助!

0 个答案:

没有答案