Learn R Programming

graphon (version 0.3.5)

gmodel.P: Generate graphs given a probability matrix

Description

Given an \((n\times n)\) probability matrix \(P\), gmodel.P generates binary observation graphs corresponding to Bernoulli distribution whose parameter matches to the element of \(P\).

Usage

gmodel.P(P, rep = 1, noloop = TRUE, symmetric.out = FALSE)

Arguments

P

an \((n\times n)\) probability matrix.

rep

the number of observations to be generated.

noloop

a logical value; TRUE for graphs without self-loops, FALSE otherwise.

symmetric.out

a logical value; FALSE for generated graphs to be nonsymmetric, TRUE otherwise. Note that TRUE is supported only if the input matrix P is symmetric.

Value

depending on rep value, either

(rep=1)

an (n-by-n) observation matrix, or

(rep>1)

a length-rep list where each element is an observation is an (n-by-n) realization from the model.

Examples

Run this code
# NOT RUN {
## set inputs
modelP <- matrix(runif(16),nrow=4)

## generate 3 observations without self-loops.
out <- gmodel.P(modelP,rep=3,noloop=TRUE)

## visualize generated graphs
opar = par(no.readonly=TRUE)
par(mfrow=c(1,3), pty="s")
image(out[[1]], main="1st sample")
image(out[[2]], main="2nd sample")
image(out[[3]], main="3rd sample")
par(opar)

# }

Run the code above in your browser using DataLab