-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Scratch code
library(fastRG)
library(tidyverse)
n <- 200
k <- 5
B <- matrix(0.01, nrow = k, ncol = k)
diag(B) <- 0.8
pi <- rep(1 / k, k)
m <- fastRG::dcsbm(
theta = stats::runif(n, min = 1, max = 3),
B = B,
pi = pi
)
EA <- m$X %*% m$S %*% t(m$X)
pop_s <- svds(EA, k)
pop_s$d
sum(EA)
A <- sample_sparse(m)
expected_edges(m)
sum(triu(A))
s <- svds(m)
s$d
expected_edges(m)
sum(triu(sample_sparse(m)))
once <- function() {
sqrt(svds(sample_sparse(m), k)$d)
}
num_reps <- 50
samp <- do.call(rbind, map(1:num_reps, ~once()))
colnames(samp) <- paste0("d", 1:k)
true <- tibble(
value = sqrt(s$d * 2),
space = paste0("d", 1:k)
)
as_tibble(samp) |>
pivot_longer(
cols = contains("d"),
names_to = "space"
) |>
ggplot(aes(value)) +
geom_histogram() +
geom_vline(data = true, mapping = aes(xintercept = value)) +
scale_fill_viridis_d() +
facet_grid(
rows = vars(space),
scales = "free_x"
) +
theme_minimal()
Metadata
Metadata
Assignees
Labels
No labels