Skip to content

Instantly share code, notes, and snippets.

@lgatto
Created September 6, 2019 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgatto/d8eb59effb815996eac789debb51690d to your computer and use it in GitHub Desktop.
Save lgatto/d8eb59effb815996eac789debb51690d to your computer and use it in GitHub Desktop.
set.seed(123)
max_corrs <- function(d, n = 60, n_iter = 1000)
replicate(n_iter, {
m <- matrix(rnorm(n * d), ncol = d)
max(cor(m)[-1, 1])
})
r1 <- data.frame(d = 800, r = max_corrs(800))
r2 <- data.frame(d = 6400, r = max_corrs(6400))
r <- rbind(r1, r2)
ggplot2::ggplot(r, aes(x = r, fill = factor(d), alpha = 0.5)) +
ggplot2::geom_density() +
ggplot2::scale_alpha(guide = "none") +
ggplot2::labs(fill = "Dimensions")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment