sample_sbm_hypergraph {HyperG}R Documentation

Sample from a stochastic block model.

Description

A stochastic block model hypergraph.

Usage

sample_sbm_hypergraph(n,P,block.sizes,d,impurity=0,variable.size=FALSE,
   absolute.purity=TRUE)

Arguments

n

number of vertices.

P

A kxk probability matrix.

block.sizes

vector of community sizes.

d

size of a hyper-edge. See Details.

impurity

See Details.

variable.size, absolute.purity

logical. See Details.

Details

A stochastic block model is first generated using the function sample_sbm(n,P,block.sizes). The edges are augmented with vertices, resulting in a stochastic block model hypergraph, as discussed below.

The variable d corresponds to the number of vertices per edge. If it is a vector, it is recycled as necessary. If variable.size is TRUE, then d is used as the mean of a Poisson random variable to generate hyper-edge orders, to which 2 is added. So a d of 2 will result in hyper-edge orders with a mean of 4.

For each edge (say, edge k) in the graph, new vertices are added so that the number of vertices in the (now hyper-)edge is d[k].

If impurity is 0, then for each edge the vertices are added in proportion to the block sizes, using sample, so if one community has many more vertices than the others, it will tend to dominate in the hyper-edges as well. However, it is guaranteed that hyper-edges between two distince communities have at least one vertex from each of those two communities, and hyper-edges within communities are pure in the case of impurity=0; no hyper-edge will contain vertices from more than two communities.

If impurity>0, then impurity of the vertices not in the original stochastic block model hypergraph are replaced by random vertices. If absolute.purity is TRUE, these new vertices are sampled from all other classes. Otherwise they are sample from vertices not in the original hyper-edge. If k is 2, only the within community hyper-edges will contain impurities.

Value

a hypergraph.

Author(s)

David J. Marchette dmarchette@gmail.com

See Also

sample_gnp_hypergraph, sample_sbm.

Examples

	
	P <- rbind(c(0.1,0.01),c(0.01,0.1))
	block.sizes <- c(50,50)
	set.seed(55)
   h <- sample_sbm_hypergraph(100,P=P,block.sizes=block.sizes,d=4)
	range(edge_orders(h))
	## should all be 4
	set.seed(1233)
	k <- sample_sbm_hypergraph(100,P=P,d=2,block.sizes=block.sizes,
	             variable.size=TRUE)
	mean(edge_orders(k))
	## should be approximately 4
	set.seed(1235)
	Q <- rbind(c(.2,.01,.01),
	           c(.01,.1,.05),
				  c(.01,.05,.2))
	kk <- sample_sbm_hypergraph(300,P=Q,d=6,block.sizes=rep(100,3),
	             variable.size=TRUE,impurity=2)

	

[Package HyperG version 1.0.0 Index]