I am trying to generate a random symmetric positive definite matrix. I'm using Julia and have made a random matrix $A$ with it. Through a google search I found an equation $\frac{1}{2}(A + A') + nI$, with A being an $n \times n$ matrix. How ever I'm not sure why that results in a positive definite matrix, so have to take there word that it does. Also I am worried that the large difference in order of magnitude between the diagonal entries and off diagonal entries when adding $nI$ for large $n$, will result in Floating point errors later down in the congratulations.
Is there a way to transform a matrix $A$ into a new matrix that is symmetric positive definite were all the values are of similar orders of magnitudes? And could you please show that the result will always be symmetric and positive definite?
To transform a matrix $A$ to a symmetric matrix, you have just to do this $$A=\frac{1}{2}(A+A'),$$ where $A'$ is the transpose of $A$.
To get a positive definite matrix, calculate $A+\lambda I$, where $\lambda$ is just greater than the smallest eigenvalue of A.