Random Matrix Generator
Generate random matrices with custom dimensions, value ranges, types (integer/float), and special structures like identity, symmetric, or triangular matrices.
About
Matrices underpin nearly every computational discipline: finite element analysis, machine learning weight initialization, graph adjacency representation, and Monte Carlo simulation all require structured random numeric grids. A poorly initialized matrix causes convergence failure in iterative solvers or introduces bias into stochastic models. This tool generates matrices of arbitrary dimension up to 100 à 100 with configurable value bounds a ⤠xij ⤠b, selectable number type (integer or floating-point with adjustable decimal precision), and sparsity control. It supports structural constraints: identity, diagonal, symmetric, upper triangular, lower triangular, and row-stochastic forms. The generator uses uniform distribution. It does not produce cryptographically secure values. For reproducible experiments, record the output. The tool approximates true randomness via the JavaScript PRNG, which is adequate for prototyping but not for production cryptography or certified statistical sampling.
Formulas
For a dense random matrix A of size m Ć n, each entry is sampled uniformly:
where a is the minimum bound, b is the maximum bound, and rand() returns a uniform variate in [0, 1). For integer output, the formula becomes:
For a symmetric matrix, only the upper triangle is generated, then mirrored: xji = xij for all i < j. For a row-stochastic matrix, each row is generated with rand() values, then normalized by dividing by the row sum Si:
The determinant (for square matrices ⤠10 à 10) is computed via Gaussian elimination with partial pivoting. The product of the diagonal after elimination gives det(A), adjusted by the sign of the permutation count.
Variable legend: m = row count, n = column count, a = minimum value, b = maximum value, xij = element at row i column j, rij = raw random value before normalization, Si = row sum for normalization.
Reference Data
| Matrix Type | Structure Rule | Typical Use Case | Square Required | Symmetry |
|---|---|---|---|---|
| Random (Dense) | All xij filled independently | Monte Carlo simulation, test data | No | None |
| Identity | xij = 1 if i = j, else 0 | Neutral element in multiplication | Yes | Symmetric |
| Diagonal | xij = 0 if i ā j | Eigenvalue matrices, scaling transforms | Yes | Symmetric |
| Symmetric | xij = xji | Covariance matrices, graph Laplacians | Yes | Symmetric |
| Upper Triangular | xij = 0 if i > j | LU decomposition, solving linear systems | Yes | None |
| Lower Triangular | xij = 0 if i < j | Cholesky factorization | Yes | None |
| Row-Stochastic | āj xij = 1, all xij ā„ 0 | Markov chains, transition probabilities | No | Rarely |
| Sparse Random | Sparsity % of entries forced to 0 | Large-scale FEM, network adjacency | No | None |
| Skew-Symmetric | xij = āxji, diagonal = 0 | Angular velocity tensors, Lie algebras | Yes | Anti-symmetric |
| Toeplitz | Constant along each diagonal | Signal processing, convolution | No | Can be symmetric |
| Hilbert | xij = 1i + j ā 1 | Numerical analysis (ill-conditioned test) | No | Symmetric |
| Vandermonde | xij = aijā1 | Polynomial interpolation | No | None |
| Permutation | Exactly one 1 per row and column | Reordering, pivoting | Yes | Orthogonal |