I am trying to randomly generate symmetric matrices $A \in \R{n \times n}$ with $-1, +1$ eigenvectors for some numerical experiments.
I want to use the eigendecomposition $A = Q \Lambda Q^{-1}$, but this requires being able to randomly generate $Q \in {-1, +1}^{n \times n}$ such that $Q$ is invertible and $A$ is symmetric.
Is there any painless way of doing this in either python or MATLAB?
I tried randomly sampling $n$ random $-1, +1 $n$-dimensional vectors to form the columns of $Q$, without any success. Basically $Q$ is never invertible when constructed in this way.
I also tried simply taking Q to be the all-ones matrix and randomly flipping the signs of elements, but I am not getting a symmetric matrix after computing $A = Q \Lambda Q^{-1}$.
I'm slightly confused by your question. I created symmetric NxN (N=30) grids containing only 1 and -1, and pretty much all of them are invertible.