User Rating 0.0 ā˜…ā˜…ā˜…ā˜…ā˜…
Total Usage 0 times
1–100
1–100
Lower bound
Upper bound
0–10 (float only)
0–99 (sparse type)
Presets:
Configure parameters above and press Generate to create a matrix.
Is this tool helpful?

Your feedback helps us improve.

ā˜… ā˜… ā˜… ā˜… ā˜…

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.

random matrix matrix generator linear algebra math tool sparse matrix identity matrix symmetric matrix

Formulas

For a dense random matrix A of size m Ɨ n, each entry is sampled uniformly:

xij = a + rand() ā‹… (b āˆ’ a)

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:

xij = floor(rand() ā‹… (b āˆ’ a + 1)) + a

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:

xij = rijSi , Si = nāˆ‘j=1 rij

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 TypeStructure RuleTypical Use CaseSquare RequiredSymmetry
Random (Dense)All xij filled independentlyMonte Carlo simulation, test dataNoNone
Identityxij = 1 if i = j, else 0Neutral element in multiplicationYesSymmetric
Diagonalxij = 0 if i ≠ jEigenvalue matrices, scaling transformsYesSymmetric
Symmetricxij = xjiCovariance matrices, graph LaplaciansYesSymmetric
Upper Triangularxij = 0 if i > jLU decomposition, solving linear systemsYesNone
Lower Triangularxij = 0 if i < jCholesky factorizationYesNone
Row-Stochasticāˆ‘j xij = 1, all xij ≄ 0Markov chains, transition probabilitiesNoRarely
Sparse RandomSparsity % of entries forced to 0Large-scale FEM, network adjacencyNoNone
Skew-Symmetricxij = āˆ’xji, diagonal = 0Angular velocity tensors, Lie algebrasYesAnti-symmetric
ToeplitzConstant along each diagonalSignal processing, convolutionNoCan be symmetric
Hilbertxij = 1i + j āˆ’ 1Numerical analysis (ill-conditioned test)NoSymmetric
Vandermondexij = aijāˆ’1Polynomial interpolationNoNone
PermutationExactly one 1 per row and columnReordering, pivotingYesOrthogonal

Frequently Asked Questions

Sparsity is applied after the structural constraint. For a symmetric matrix, a cell selected for zeroing at position (i, j) also forces (j, i) to zero, preserving symmetry. For triangular matrices, sparsity only affects the non-zero triangle. Identity matrices ignore sparsity entirely since their structure is fixed.
Gaussian elimination runs in O(n³) time. For a 100Ɨ100 matrix that is 1,000,000 operations which, while feasible, produces floating-point drift that makes the result unreliable without arbitrary-precision arithmetic. The 10Ɨ10 cap keeps computation under 1,000 operations and maintains at least 10 significant digits of accuracy with IEEE 754 doubles.
They are pseudorandom, produced by the JavaScript engine's Math.random() PRNG (typically xorshift128+ or similar). The distribution is uniform over [0, 1). This is sufficient for prototyping, test data generation, and educational purposes. For cryptographic or certified statistical applications, use a CSPRNG such as crypto.getRandomValues().
The tool automatically swaps the values so that the lower bound is always min and the upper bound is always max. A toast notification informs you of the correction. This prevents empty or undefined output ranges.
No. Identity, diagonal, symmetric, skew-symmetric, upper triangular, lower triangular, and permutation types require square matrices by mathematical definition. If you select one of these types, the column count automatically locks to equal the row count. Dense random, sparse, row-stochastic, Hilbert, Vandermonde, and Toeplitz types support rectangular dimensions.
Each row is filled with independent uniform random values in (0, 1), then every element is divided by the row's total sum. This guarantees each row sums to exactly 1.0 (within floating-point precision, approximately 15 significant digits). All entries remain non-negative, satisfying both conditions of a stochastic matrix.