Is there a way to create random real antisymmetric matrix in Mathematica. Please see the example of such a matrix.
3 Answers
Here's a version which allows you to specify a distribution and only generates the required number of random draws for a symmetric matrix. You could replace the RandomVariate[...]
code with something like RandomInterger[]
if you'd like.
(*Dimension*)
n = 3;
(*Distribution*)
dist = NormalDistribution[];
(*Construct upper triangular SparseArray, efficiently only creating n*(n-1)/2 random numbers.*)
s = SparseArray[{i_, j_} /; i < j :> RandomVariate[dist], {n, n}];
(*Create antisymmetric matrix.*)
m = Normal[s - Transpose[s]];
AntisymmetricMatrixQ[m]
(*True*)
If you don't mind the distribution of generated matrices:
m = RandomInteger[{0, 50}, {3, 3}];
result = m - Transpose[m]
AntisymmetricMatrixQ[result] (* True *)
```
You can use SymmetrizedArray
to create arrays with any kind of symmetry:
Normal @ SymmetrizedArray[
RandomInteger[10, {3, 3}],
Automatic,
Antisymmetric[{1, 2}]
]
n = 10 ; a = RandomReal[{0.0, 1.0}, {n, n}] ; b = 0.5*(a - Transpose[a]) ; AntisymmetricMatrixQ[b]
$\endgroup$