sample_tdcsbm: Sample truncated DCSBM (fast)

View source: R/models.R

sample_tdcsbmR Documentation

Sample truncated DCSBM (fast)

Description

Sample an adjacency matrix from a truncated degree-corrected block model (DCSBM) using a fast algorithm.

Usage

sample_tdcsbm(z, B, theta = 1)

Arguments

z

Node labels (n * 1)

B

Connectivity matrix (K * K)

theta

Node connectivity propensity vector (n * 1)

Details

The function samples an adjacency matrix from a truncated DCSBM, with entries having Bernoulli distributions with mean

E[A_{ij} | z] = B_{z_i, z_j} \min(1, θ_i θ_j).

The approach uses the masking idea of Aiyou Chen, leading to fast sampling for sparse networks. The masking, however, truncates θ_i θ_j to at most 1, hence we refer to it as the truncated DCSBM.

Value

An adjacency matrix following DCSBM

Examples

B = pp_conn(n = 10^4, oir = 0.1, lambda = 7, pri = rep(1,3))$B
head(sample_tdcsbm(sample(1:3, 10^4, replace = TRUE), B, theta = rexp(10^4)))

aaamini/nett documentation built on Nov. 12, 2022, 6:25 p.m.