Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. set.seed(pi)
  2. n <- 10 # number of data points (observations)
  3. d_max <- 1000 # max dimension
  4. dist1 <- rep(0, d_max)
  5. disc <- rep(0, d_max)
  6. for (d in 1:d_max) {
  7. A <- matrix(runif(n*d), nrow=n, ncol=d)
  8. distances <- as.vector(dist(A))
  9. disc[d] <- ( max(distances) - min(distances) )/min(distances)
  10. }
  11. plot(11:d_max, disc[11:d_max], xlab = "d", ylab = "(dist_max - dist_min) / dist_min", pch = 19)
  12.  
  13. [1] 12.90191 12.97374 12.89478 13.13179 12.52021 13.12185 13.13992 12.74864 12.94139 12.93830 12.93154 12.82812 13.24305 12.78545 12.94532 12.82877 13.22162 [18] 12.86434 12.58688 13.16338 12.84874 13.05939 12.87777 12.85084 12.30536 12.68565 13.03605 13.31366 12.37667 12.90180 12.97520 12.62158 12.89200 13.08616 [35] 12.70571 13.13252 12.88714 12.75688 12.84972 12.94311 12.67934 12.84256 13.28620 13.05672 12.87923
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement