Title: | Random Matrix Analysis Toolkit |
---|---|
Description: | Simulate random matrices and ensembles and compute their eigenvalue spectra and dispersions. |
Authors: | Ali Taqi [aut, cre], Jonathan Wells [ths] |
Maintainer: | Ali Taqi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2025-02-10 06:01:15 UTC |
Source: | https://github.com/eli-fidele/rmat |
Returns a vector of the eigenvalue spacings of a random matrix or ensemble.
dispersion( array, pairs = NA, norm_order = TRUE, singular = FALSE, pow_norm = 1 )
dispersion( array, pairs = NA, norm_order = TRUE, singular = FALSE, pow_norm = 1 )
array |
a square matrix or matrix ensemble whose eigenvalue spacings are to be returned |
pairs |
a string argument representing the pairing scheme to use |
norm_order |
sorts the eigenvalue spectrum by its norms if TRUE, otherwise sorts them by sign |
singular |
return the singular values of the matrix or matrix ensemble |
pow_norm |
power to raise norm to - defaults to 1 (the standard absolute value); otherwise raises norm to the power of argument (beta norm) |
A tidy dataframe with the real & imaginary components of the eigenvalues and their norms along with a unique index.
# Eigenvalue dispersion of a normal matrix using the lower pair scheme P <- RM_norm(N = 5) disp_P <- dispersion(P, pairs = "lower") # Eigenvalue dispersion of a stochastic matrix (using the consecutive pair scheme) Q <- RM_stoch(N = 5) disp_Q <- dispersion(Q) # Eigenvalue dispersion of an normal matrix ensemble, ordering by sign instead of norm. ens <- RME_beta(N = 10, beta = 2, size = 10) disp_ens <- dispersion(ens, norm_order = FALSE)
# Eigenvalue dispersion of a normal matrix using the lower pair scheme P <- RM_norm(N = 5) disp_P <- dispersion(P, pairs = "lower") # Eigenvalue dispersion of a stochastic matrix (using the consecutive pair scheme) Q <- RM_stoch(N = 5) disp_Q <- dispersion(Q) # Eigenvalue dispersion of an normal matrix ensemble, ordering by sign instead of norm. ens <- RME_beta(N = 10, beta = 2, size = 10) disp_ens <- dispersion(ens, norm_order = FALSE)
-matrixHermite- ensemble matrices are matrices with normal entries and beta real number components.
Using Dumitriu's tridiagonal model, this function is an implementation of the generalized, but not necessarily invariant,
beta ensembles for
> 0.
RM_beta(N, beta)
RM_beta(N, beta)
N |
number of dimensions of the square matrix |
beta |
the value of the beta parameter for the beta ensemble |
A random Hermite beta matrix with any integer parameter beta
# Generate a 3x3 random beta matrix with beta = 4 P <- RM_beta(N = 3, beta = 4) # Generate a 10x10 random beta matrix with beta = 25 P <- RM_beta(N = 10, beta = 25)
# Generate a 3x3 random beta matrix with beta = 4 P <- RM_beta(N = 3, beta = 4) # Generate a 10x10 random beta matrix with beta = 25 P <- RM_beta(N = 10, beta = 25)
An Erdos-Renyi Graph is a graph whose edges are connected ~ Bern(p). Hence, its transition matrix will have nonzero entries with that probability. So, we can alternatively think of the transition matrix for such walk as a stochastic matrix with parameterized sparsity.
RM_erdos(N, p)
RM_erdos(N, p)
N |
number of dimensions of the square matrix |
p |
the probability two vertices are connected in an Erdos-Renyi graph. |
A random stochastic matrix corrosponding to a walk on an Erdos-Renyi graph with probability p.
# Very sparse graph P <- RM_erdos(N = 3, p = 0.2) # Slightly sparse graph P <- RM_erdos(N = 9, p = 0.6) # Completely connected graph P <- RM_erdos(N = 5, p = 1)
# Very sparse graph P <- RM_erdos(N = 3, p = 0.2) # Slightly sparse graph P <- RM_erdos(N = 9, p = 0.6) # Completely connected graph P <- RM_erdos(N = 5, p = 1)
Normal random matrices are matrices with normally distributed entries. These matrices are extensively studied in random matrix theory.
RM_norm(N, mean = 0, sd = 1, symm = FALSE, cplx = FALSE, herm = FALSE)
RM_norm(N, mean = 0, sd = 1, symm = FALSE, cplx = FALSE, herm = FALSE)
N |
number of dimensions of the square matrix |
mean |
mean of the normal distribution of entries |
sd |
standard deviation of the normal distribution of entries |
symm |
indicates whether the matrix should be symmetric (equal to its transpose). Reserved for when cplx = FALSE, otherwise use herm = TRUE. |
cplx |
indicates whether the matrix should have complex entries. |
herm |
indicates whether the matrix should be hermitian (equal to its conjugate transpose). Reserved for when cplx = TRUE, otherwise use symm = TRUE. |
A random matrix with normally distributed entries.
# N(1,2) distributed matrix P <- RM_norm(N = 3, mean = 1, sd = 2) # N(0,5) distributed matrix with real symmetric entries P <- RM_norm(N = 7, sd = 5, symm = TRUE) # 7x7 standard normal matrix with complex entries Q <- RM_norm(N = 7, cplx = TRUE) # N(2,1) distributed matrix with hermitian complex entries Q <- RM_norm(N = 5, mean = 2, cplx = TRUE, herm = TRUE)
# N(1,2) distributed matrix P <- RM_norm(N = 3, mean = 1, sd = 2) # N(0,5) distributed matrix with real symmetric entries P <- RM_norm(N = 7, sd = 5, symm = TRUE) # 7x7 standard normal matrix with complex entries Q <- RM_norm(N = 7, cplx = TRUE) # N(2,1) distributed matrix with hermitian complex entries Q <- RM_norm(N = 5, mean = 2, cplx = TRUE, herm = TRUE)
A (row-)stochastic matrix is a matrix whose rums sum to 1. There is a natural one-to-one corrospondence between stochastic matrices and Markov Chains; this is so when its i,j entry represent the transition probability from state i to state j.
RM_stoch(N, symm = FALSE, sparsity = FALSE)
RM_stoch(N, symm = FALSE, sparsity = FALSE)
N |
number of dimensions of the square matrix |
symm |
indicates whether the matrix should be symmetric; equal to its transpose. |
sparsity |
indicates whether the matrix should add some arbitrary sparsity (zeros) |
A random stochastic matrix.
P <- RM_stoch(N = 3) P <- RM_stoch(N = 9, sparsity = TRUE) Q <- RM_stoch(N = 9, symm = TRUE) Q <- RM_stoch(N = 9, symm = TRUE, sparsity = TRUE)
P <- RM_stoch(N = 3) P <- RM_stoch(N = 9, sparsity = TRUE) Q <- RM_stoch(N = 9, symm = TRUE) Q <- RM_stoch(N = 9, symm = TRUE, sparsity = TRUE)
Generate a tridiagonal matrix with normal entries
RM_trid(N, symm = FALSE)
RM_trid(N, symm = FALSE)
N |
number of dimensions of the square matrix |
symm |
indicates whether the matrix should be symmetric; equal to its transpose. |
A random tridiagonal matrix with N(0,2) diagonal and N(0,1) band.
# Generate a 3x3 standard normal tridiagonal matrix P <- RM_trid(N = 3) # Symmetric tridiagonal matrix P <- RM_trid(N = 9, symm = TRUE)
# Generate a 3x3 standard normal tridiagonal matrix P <- RM_trid(N = 3) # Symmetric tridiagonal matrix P <- RM_trid(N = 9, symm = TRUE)
Uniform random matrices are matrices with uniformly distributed entries. They are an elementary type of random matrix.
RM_unif(N, min, max, symm = FALSE, cplx = FALSE, herm = FALSE)
RM_unif(N, min, max, symm = FALSE, cplx = FALSE, herm = FALSE)
N |
number of dimensions of the square matrix |
min |
minimum of the uniform distribution to be sampled from |
max |
maximum of the uniform distribution to be sampled from |
symm |
indicates whether the matrix should be symmetric (equal to its transpose). |
cplx |
indicates whether the matrix should have complex entries. |
herm |
indicates whether the matrix should be hermitian (equal to its conjugate transpose). Reserved for when cplx = TRUE, otherwise use symm = TRUE. |
A random matrix with uniformly distributed entries.
# Unif(1,2) distributed matrix P <- RM_unif(N = 3, min = 1, max = 2) # Unif(0,5) distributed matrix with real symmetric entries P <- RM_unif(N = 7, min = 0, max = 5, symm = TRUE) # Unif(0,1) distributed matrix with complex entries Q <- RM_unif(N = 7, min = 0, max = 1, cplx = TRUE) # Unif(2,10) distributed matrix with hermitian complex entries Q <- RM_unif(N = 5, min = 2, max = 10, cplx = TRUE, herm = TRUE)
# Unif(1,2) distributed matrix P <- RM_unif(N = 3, min = 1, max = 2) # Unif(0,5) distributed matrix with real symmetric entries P <- RM_unif(N = 7, min = 0, max = 5, symm = TRUE) # Unif(0,1) distributed matrix with complex entries Q <- RM_unif(N = 7, min = 0, max = 1, cplx = TRUE) # Unif(2,10) distributed matrix with hermitian complex entries Q <- RM_unif(N = 5, min = 2, max = 10, cplx = TRUE, herm = TRUE)
Given the same arguments as RM_norm, this function returns an ensemble of that particular class of matrix. While random matrices usually do not exude unique properties on their own, they do indeed have deterministic properties at the ensemble level in terms of their spectral statistics.
RME_beta(N, beta, size)
RME_beta(N, beta, size)
N |
number of dimensions of the square matrix |
beta |
the value of the beta parameter for the beta ensemble |
size |
the size of the ensemble (i.e. number of matrices) |
An ensemble (list) of beta matrices as specified by the matrix arguments.
# Generate an ensemble of 10x10 beta matrices with beta = 4 of size 100. ensemble <- RME_beta(N = 10, beta = 4, size = 100)
# Generate an ensemble of 10x10 beta matrices with beta = 4 of size 100. ensemble <- RME_beta(N = 10, beta = 4, size = 100)
Given the same arguments as RM_norm, this function returns an ensemble of random Erdos-Renyi stochastic matrices. While random matrices usually do not exude unique properties on their own, they do indeed have deterministic properties at the ensemble level in terms of their spectral statistics.
RME_erdos(N, p, size)
RME_erdos(N, p, size)
N |
number of dimensions of the square matrix |
p |
the probability two vertices are connected in an Erdos-Renyi graph. |
size |
the size of the ensemble (i.e. number of matrices) |
An ensemble (list) of Erdos-Renyi transition matrices as specified by the matrix arguments.
# Generate an ensemble of 10x10 Erdos-Renyi transition matrices of size 50 with p = 0.7 ensemble <- RME_erdos(N = 10, p = 0.7, size = 50)
# Generate an ensemble of 10x10 Erdos-Renyi transition matrices of size 50 with p = 0.7 ensemble <- RME_erdos(N = 10, p = 0.7, size = 50)
Given the same arguments as RM_norm, this function returns an ensemble of random normal matrices. While random matrices usually do not exude unique properties on their own, they do indeed have deterministic properties at the ensemble level in terms of their spectral statistics.
RME_norm(N, mean = 0, sd = 1, ..., size)
RME_norm(N, mean = 0, sd = 1, ..., size)
N |
number of dimensions of the square matrix |
mean |
mean of the normal distribution of entries |
sd |
standard deviation of the normal distribution of entries |
... |
any default-valued parameters taken as arguments by RM_norm() |
size |
the size of the ensemble (i.e. number of matrices) |
An ensemble (list) of normal matrices as specified by the matrix arguments.
# Generate an ensemble of standard normal 3x3 matrices of size 20 ensemble <- RME_norm(N = 3, size = 20)
# Generate an ensemble of standard normal 3x3 matrices of size 20 ensemble <- RME_norm(N = 3, size = 20)
Given the same arguments as RM_stoch, this function returns an ensemble of random stochastic matrices. While random matrices usually do not exude unique properties on their own, they do indeed have deterministic properties at the ensemble level in terms of their spectral statistics.
RME_stoch(N, ..., size)
RME_stoch(N, ..., size)
N |
number of dimensions of the square matrix |
... |
pass any default-valued parameters taken as arguments by RM_stoch() |
size |
the size of the ensemble (i.e. number of matrices) |
An ensemble (list) of stochastic matrices as specified by the matrix arguments.
# Generate an ensemble of random 5x5 transition matrices of size 20. ensemble <- RME_stoch(N = 5, size = 20) # Generate an ensemble of symmetric random 5x5 transition matrices of size 20. ensemble <- RME_stoch(N = 5, symm = TRUE, size = 20)
# Generate an ensemble of random 5x5 transition matrices of size 20. ensemble <- RME_stoch(N = 5, size = 20) # Generate an ensemble of symmetric random 5x5 transition matrices of size 20. ensemble <- RME_stoch(N = 5, symm = TRUE, size = 20)
Given the same arguments as RM_norm, this function returns an ensemble of random normal matrices. While random matrices usually do not exude unique properties on their own, they do indeed have deterministic properties at the ensemble level in terms of their spectral statistics.
RME_unif(N, min, max, ..., size)
RME_unif(N, min, max, ..., size)
N |
number of dimensions of the square matrix |
min |
minimum of the uniform distribution to be sampled from |
max |
maximum of the uniform distribution to be sampled from |
... |
any default-valued parameters taken as arguments by RM_norm() |
size |
the size of the ensemble (i.e. number of matrices) |
An ensemble (list) of normal matrices as specified by the matrix arguments.
# Generate an ensemble of standard normal 3x3 matrices of size 20 ensemble <- RME_norm(N = 3, size = 20)
# Generate an ensemble of standard normal 3x3 matrices of size 20 ensemble <- RME_norm(N = 3, size = 20)
Returns a tidied dataframe of the eigenvalues of a random matrix or ensemble.
spectrum( array, norm_order = TRUE, singular = FALSE, components = TRUE, order = NA )
spectrum( array, norm_order = TRUE, singular = FALSE, components = TRUE, order = NA )
array |
a square matrix or matrix ensemble whose eigenvalues are to be returned |
norm_order |
sorts the eigenvalue spectrum by its norms if TRUE, otherwise sorts them by sign |
singular |
return the singular values of the matrix or matrix ensemble |
components |
returns the array with resolved real and imaginary components if TRUE, otherwise returns complex-valued eigenvalues |
order |
an integer or integer vector of which eigenvalue orders to return; order 1 representing the largest, order N represents smallest (where N is the number of eigenvalues). If uninitialized, defaults to returning the entire spectrum. |
A tidy dataframe with the real & imaginary components of the eigenvalues and their norms along with a unique index.
# Eigenvalue spectrum of a random normal matrix P <- RM_norm(N = 5) spec_P <- spectrum(P) Q <- matrix(runif(2^2), ncol = 2) spec_Q <- spectrum(Q) # Eigenvalue spectra of ensemble matrices ens <- RME_norm(N = 3, size = 10) spec_ens <- spectrum(ens)
# Eigenvalue spectrum of a random normal matrix P <- RM_norm(N = 5) spec_P <- spectrum(P) Q <- matrix(runif(2^2), ncol = 2) spec_Q <- spectrum(Q) # Eigenvalue spectra of ensemble matrices ens <- RME_norm(N = 3, size = 10) spec_ens <- spectrum(ens)