gmodel.P function

Generate graphs given a probability matrix

Generate graphs given a probability matrix

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

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

Arguments

  • P: an (n×n)(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.

Returns

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

## 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)
  • Maintainer: Kisung You
  • License: MIT + file LICENSE
  • Last published: 2021-08-13

Useful links