Learn R Programming

RMThreshold (version 1.1)

create.rand.mat: Create a real-valued, symmetric random matrix

Description

The function creates a real-valued, symmetric random matrix of desired dimension. Two alternatives for the probability distribution of the matrix elements are provided.

Usage

create.rand.mat(size = 1000, distrib = c("norm", "unif"), mean = 0, stddev = 1)

Arguments

size
Dimension of the (quadratic) matrix.
distrib
Desired probability distribution of the matrix elements. Can be norm or unif.
mean
Desired mean of the normal distribution. Only active if distrib = 'norm' was chosen.
stddev
Desired standard deviation of the normal distribution. Only active if distrib = 'norm' was chosen.

Value

A list containing the following components:
mean.diag
The mean of the diagonal elements of the matrix.
stddev.diag
The standard deviation of the diagonal elements of the matrix.
mean.triangle
The mean of the upper triangle of the matrix (diagonal excluded).
stddev.triangle
The standard deviation of the upper triangle of the matrix (diagonal excluded).
rand.matrix
The random matrix created.

Details

The function creates a real-valued, symmetrical random matrix of desired dimension. Two alternatives for the probability distribution of the matrix elements are provided: normal and uniform. If distrib = 'norm', the mean and the standard deviation can additionally be chosen. If distrib = 'unif', the matrix elements will be uniformly distributed in the interval (-1,1).

Examples

Run this code
  set.seed(777)
  random.matrix <- create.rand.mat(size = 1000, distrib = "norm")$rand.matrix
  dim(random.matrix)

Run the code above in your browser using DataLab