gzomat: Generate a zero-one matrix.

Description Usage Arguments Value Examples

View source: R/gzomat.R

Description

This function returns a zero-one matrix with given dimension and non-zero probability

Usage

1
gzomat(m, n, p)

Arguments

m

m is the row dimension of matrix.

n

n is the column dimension of matrix.

p

p is the non-zero probability of matrix.

Value

M is a zero-one matrix with given dimension and non-zero probability.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (m, n, p)
{
    M <- matrix(0, m, n)
    index <- c(1:(m * n))
    index <- sample(index, round(p * m * n), replace = FALSE)
    M[index] <- 1
    return(M)
  }

xzheng-ac/scPADGRN documentation built on July 26, 2020, 12:41 a.m.