# Generate random Hermitian matrices [duplicate]

I want to generate random Hermitian matrices. For now, random Hermitian matrices with size 2 are obvious to construct. But elegant methods for higher dimension would be nice! Are there methods besides just randomly generating the upper triangular entires and then conjugating each entries to fill in the lower half? Thanks!!

## marked as duplicate by Sjoerd C. de Vries, Community♦Dec 11 '15 at 19:29

• You can adapt the solution in this answer to your case; just make sure the random eigenvalues are real. – J. M. will be back soon Dec 11 '15 at 19:14
• Alternatively, generate a random matrix $A$ and take $\frac12(A+A^\dagger)$. – Rahul Dec 11 '15 at 19:22
• Very helpful thank you guys!!! – nekodesu Dec 11 '15 at 19:27

a = Table[
Which[x == y, RandomReal[], x < y, RandomComplex[], x > y, 0],
{x, 5}, {y, 5}];

b = Table[
If[x <= y, a[[x, y]], Conjugate[a[[y, x]] ]],
{x, 5}, {y, 5}];

HermitianMatrixQ[b]


(* True *)

Or the simplest (given by Rahul):

1/2 ((a = Table[RandomComplex[], {5}, {5}]) + ConjugateTranspose[a]);

HermitianMatrixQ[%]


(* True *)